Yaf_Application::bootstrap
Yaf_Application::bootstrap
(Yaf >=1.0.0)
Yaf_Application::bootstrap - 调用引导程序
描述
public void Yaf_Application::bootstrap ([ Yaf_Bootstrap_Abstract $bootstrap ] )
运行Bootstrap,在Bootstrap中定义的所有方法都会根据它们的声明顺序被调用,如果未提供参数bootstrap,Yaf将在application.directory下查找Bootstrap。
参数
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__) //__DIR__ was introduced after PHP 5.3
$application = new Yaf_Application(APPLICATION_PATH.'/conf/application.ini'
$application->bootstrap(
?>
上面的例子会输出类似于:
1st called
2nd called
另请参阅
- Yaf_Bootstrap_Abstract
Yaf_Application::clearLastError →