Bancha 1: Installation

Note: This is the documentation for Bancha 1. You can find the current documentation here.

Prerequisites

  1. You have downloaded and installed the lasted release of CakePHP 2.
  2. You have downloaded the lastest release of ExtJS 4 and/or Sencha Touch 2

Note that you might have to buy a commercial ExtJS license, see http://www.sencha.com/products/extjs/license/

Installation

  1. Download the Bancha source and place it into the plugins folder of your existing CakePHP installation. (You should then either have a plugins/Bancha or app/Plugin/Bancha folder).
  2. Write at the end of your bootstrap (app/Config/bootstrap.php):
    CakePlugin::load(array(
        'Bancha' => array(
            'routes' => true,
            'bootstrap' => true
        )));
    
  3. Copy the file app/Plugin/Bancha/_app/webroot/bancha-dispatcher.php to app/webroot/bancha-dispatcher.php
  4. Add the BanchaPaginatorComponent to your AppController:
    /**
     * Use the BanchaPaginatorComponent to also support pagination
     * and remote searching for Sencha Touch and ExtJS stores
     */
    public $components = array('Session', 'Paginator' => array('className' => 'Bancha.BanchaPaginator'));
    
  5. For production you may want to add a caching provider, since Bancha uses reflection. For default configuration add this at the end of app/Config/core.php (please make sure you are using the CakePHP 2.1.0+ core.php, otherwise $prefix is not defined):
    /**
     * Configure the cache for Banchas Remote API.
     */
    Cache::config('_bancha_api_', array(
        'engine' => $engine,
        'prefix' => $prefix . 'bancha_api_',
        'path' => CACHE . 'models' . DS,
        'serialize' => ($engine === 'File'),
        'duration' => $duration
    ));
    

Setting up ExtJS

  1. Place ext-all.js and ext-all-dev.js into app/webroot/js/ and the ExtJS resources folder into app/webroot/css/

  2. Include ExtJS and the files /bancha/js/Bancha.js (a javascript file inside the plugin folder) and /bancha-api.js (a CakePHP page, created by the Bancha plugin). 
    For production usage you may want to add a parameter to already load all metadata on startup: /bancha-api/models/all.js or /bancha-api/models/[Article,User].js.

    Code for a plain html file:

    <!-- include ExtJS css -->
    <link rel="stylesheet" href="/css/resources/css/ext-all.css" type="text/css" />
    
    <!-- include ExtJS -->
    <script type="text/javascript" src="/js/ext-all-dev.js"></script>
    
    <!-- include Bancha and the remote API -->
    <script type="text/javascript" src="/Bancha/js/Bancha-dev.js"></script> <!-- for the github version use /Bancha/js/Bancha.js -->
    <script type="text/javascript" src="/bancha-api/models/all.js"></script>
    

    Code for cake layouts:

    <?php
        echo $this->Html->css('resources/css/ext-all');
        echo $this->Html->script('ext-all-dev');
        echo $this->Html->script('/Bancha/js/Bancha-dev'); <!-- for the github version use /Bancha/js/Bancha -->
        echo $this->Html->script('/bancha-api/models/all');
    ?>
    

Setting up Sencha Touch

  1. Place sencha-touch-all.js and sencha-touch-debug.js into app/webroot/js/ and the Sencha Touch resources folder into app/webroot/css/

  2. To use Bancha in a layout include Sencha Touch, and the files /bancha-api.js and /bancha/js/Bancha.js into your layout. For production usage you may want to add a parameter to already load all metadata on startup: /bancha-api/models/all.js or /bancha-api/models/[Article,User].js. Example:

    <!-- include Sencha Touch css -->
    <link rel="stylesheet" href="/css/resources/css/sencha-touch.css" />
    
    <!-- include Sencha Touch -->
    <script type="text/javascript" src="/js/sencha-touch-all-debug.js"></script>
    
    <!-- include Bancha and the remote API -->
    <script type="text/javascript" src="/Bancha/js/Bancha-dev.js"></script> <!-- for the github version use /Bancha/js/Bancha.js -->
    <script type="text/javascript" src="/bancha-api/models/all.js"></script>
    

Trouble shooting

After you have successfully finished installation you can open the page /Bancha/setup-check.html to find any installation problem.

For questions write us a mail: support@banchaproject.org

Comments

Add a comment