php:fuelphp

文書の過去の版を表示しています。


FuelPHP

  1. development の接続設定を行う。
    fuelapp/fuel/app/config/development/db.php
    <?php
    /**
     * The development database settings.
     */
     
    return array(
        'default' => array(
            'connection'  => array(
                'dsn'        => 'mysql:host=localhost;dbname=fuel_db',
                'username'   => 'fuel_app',
                'password'   => 'password',
            ),
        ),
    );
  2. production の接続設定を行う。
    fuelapp/fuel/app/config/production/db.php
    <?php
    /**
     * The production database settings.
     */
     
    return array(
        'default' => array(
            'connection'  => array(
                'dsn'        => 'mysql:host=localhost;dbname=fuel_db',
                'username'   => 'fuel_app',
                'password'   => 'password',
            ),
        ),
    );
  3. ベースのデータベース設定を行う。
    <?php
    /**
     * Base Database Config.
     *
     * See the individual environment DB configs for specific config information.
     */
     
    return array(
        'active' => 'default',
     
        /**
         * Base config, just need to set the DSN, username and password in env. config.
         */
        'default' => array(
            //'type'        => 'pdo',
            'type'        => 'mysqli',
            'connection'  => array(
                'persistent' => false,
            ),
            'identifier'   => '`',
            'table_prefix' => '',
            'charset'      => 'utf8',
            'enable_cache' => true,
            'profiling'    => false,
        ),
     
        'redis' => array(
            'default' => array(
                'hostname'  => '127.0.0.1',
                'port'      => 6379,
                'timeout'    => null,
            )
        ),
     
    );
  4. O/R マッパーを有効化する。
    fuel/app/config/config.php
    'packages'  => array(
        'orm', // Ormを有効化
    ),
  • Smarty は以下のように配置する。
    fuelapp/fuel/app/vendor/
        +- [Smarty]
             +- [libs]
                 +- [plugins]
                 +- [sysplugins]
                 +- debug.tpl
                 +- Smarty.class.php
                 +- SmartyBC.class.php
  1. Smarty のリポジトリから取得する。
    $ cd fuelapp/fuel/app/vendor/
    $ svn checkout http://smarty-php.googlecode.com/svn/trunk/distribution Smarty
  2. demo は要らないので削除する。
    $ rm -rf Smarty/demo/
  3. fuel-smarty をインストールする。
    $ cd fuelapp/fuel/packages/
    $ git clone https://github.com/ttoz/fuel-smarty
  4. Smarty と fuel-smarty を有効化する。
    fuel/app/config/config.php
    'packages'  => array(
        'parser',       // Smartyを有効化
        'fuel-smarty',  // Fuel-Smartyを有効化
    ),
  5. parser の設定ファイルをコピーする。
    fuelapp/fuel/packages/parser/config/parser.php → fuelapp/fuel/app/config/parser.php
    $ cp fuelapp/fuel/packages/parser/config/parser.php fuelapp/fuel/app/config/parser.php 
  1. ルーティングを追記する。
    fuelapp/fuel/app/config/routes.php
    <?php
    return array(
        'smartytest'    => 'smartytest/index',
    );
  2. コントローラのコードを作成する。
    fuelapp/fuel/app/classes/controller/smartytest.php
    <?php
    class Controller_SmartyTest extends Controller
    {
        function action_index()
        {
            return Response::forge(View_SmartyTest::forge('smartytest'));
        }
    }
  3. ビューモデルのコードを作成する。
    fuelapp/fuel/app/classes/view/smartytest.php
    <?php
    class View_SmartyTest extends ViewModel
    {
        function view()
        {
            $this->title = 'Smarty Test';
        }
    }
  4. Smarty のテンプレートを作成する。
    fuelapp/fuel/app/views/smartytest.smarty
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>{$title}</title>
    </head>
    <body>
        <p>{$title}</p>
    </body>
    </html>
  5. http://fuelapp.localhost/smartytest にアクセスして動作を確認する。
  • php/fuelphp.1352664386.txt.gz
  • 最終更新: 2019/05/18 02:23
  • (外部編集)