Yaf_Application::bootstrap

(Yaf >=1.0.0)

Yaf_Application::bootstrap调用bootstrap

说明

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

指示Yaf_Application去寻找Bootstrap,并按照声明的顺序,执行所有在Bootstrap类中定义的以_init开头的方法。 如果没有提供变量bootstrap,Yaf默认会去application.directory中寻找Bootstrap。

参数

bootstrap

A Yaf_Bootstrap_Abstract instance

返回值

Yaf_Application instance

范例

示例 #1 A Bootstrap()example

<?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()example

<?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