Yaf_Application::bootstrap

(Yaf >=1.0.0)

Yaf_Application::bootstrap调用 bootstrap

说明

publicYaf_Application::bootstrap(Yaf_Bootstrap_Abstract$bootstrap = ?): void

运行 Bootstrap,所有在 Bootstrap 中定义并以“_init”前缀命名的方法都将按照声明的顺序调用,如果没有提供参数 bootstrap,Yaf 将在 application.directory 下寻找 Bootstrap。

参数

bootstrap

Yaf_Bootstrap_Abstract 实例

返回值

Yaf_Application 实例

示例

示例 #1 Bootstrap() 示例

<?php

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
To Top