array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'class.yaf-bootstrap-abstract.php', 1 => 'Yaf_Bootstrap_Abstract', ), 'up' => array ( 0 => 'book.yaf.php', 1 => 'Yaf', ), 'prev' => array ( 0 => 'yaf-application.setappdirectory.php', 1 => 'Yaf_Application::setAppDirectory', ), 'next' => array ( 0 => 'class.yaf-dispatcher.php', 1 => 'Yaf_Dispatcher', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'ja', 'path' => 'reference/yaf/yaf-bootstrap-abstract.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(No version information available, might only be in Git)
ブートストラップとは、アプリケーションを実行する前の初期設定に使う仕組みのことです。
ユーザーが自前のブートストラップクラスを定義するには、 Yaf_Bootstrap_Abstract を継承します。
ブートストラップクラスで定義したメソッドの中で "_init" で始まるものがすべて、定義した順に Yaf_Application::bootstrap() から呼ばれます。
例1 ブートストラップの例
<?php
/* ブートストラップクラスは ./application/Bootstrap.php で定義しないといけません */
class Bootstrap extends Yaf_Bootstrap_Abstract {
public function _initConfig(Yaf_Dispatcher $dispatcher) {
var_dump(__METHOD__);
}
public function _initPlugin(Yaf_Dispatcher $dispatcher) {
var_dump(__METHOD__);
}
}
$config = array(
"application" => array(
"directory" => dirname(__FILE__) . "/application/",
),
);
$app = new Yaf_Application($config);
$app->bootstrap();
?>
上の例の出力は、 たとえば以下のようになります。
string(22) "Bootstrap::_initConfig" string(22) "Bootstrap::_initPlugin"