« Yaf_Application::app
Yaf_Application::clearLastError »

Yaf_Application::bootstrap

(Yaf >=1.0.0)

Yaf_Application::bootstrap — ブートストラップをコールする

説明

public function Yaf_Application::bootstrap(Yaf_Bootstrap_Abstract $bootstrap = ?): void

ブートストラップを実行します。"_init" で始まる名前のすべてのメソッドを その定義順に実行します。bootstrap パラメータを省略した場合は、 application.directory からブートストラップを探します。

パラメータ

bootstrap

Yaf_Bootstrap_Abstract のインスタンス。

戻り値

Yaf_Application のインスタンスを返します。

例

例1 Bootstrap の例

<?php
/**
 * This file should be under the APPLICATION_PATH . "/application/"(which was defined in the config passed to Yaf_Application).
 * and named Bootstrap.php,  so the Yaf_Application can find it 
 */
class Bootstrap extends Yaf_Bootstrap_Abstract {
    function _initConfig(Yaf_Dispatcher $dispatcher) {
        echo "1st called\n";
    }

    function _initPlugin($dispatcher) {
        echo "2nd called\n";
    }
}
?>

例2 Yaf_Application::bootstrap() の例

<?php

defined('APPLICATION_PATH') // APPLICATION_PATH will be used in the ini config file
    || define('APPLICATION_PATH', __DIR__);

$application = new Yaf_Application(APPLICATION_PATH.'/conf/application.ini');
$application->bootstrap();
?>

上の例の出力は、 たとえば以下のようになります。

1st called
2nd called
関連キーワード:
Application   bootstrap   Bootstrap   ブートストラップ   application   Abstract   called   インスタンス   defined   config   dispatcher   2nd   clearLastError   init   省略   directory   passed   named   find   extends   initConfig   Dispatcher   initPlugin   used   define
関連する関数・ページ:
class.yaf-bootstrap-abstract   yaf-application.construct   class.yaf-application   yaf-application.clearlasterror   yaf-application.app   yaf-application.getconfig