Yaf_Application::bootstrap
(Yaf >=1.0.0)
Yaf_Application::bootstrap — Call bootstrap
Description
Run a Bootstrap. All the public methods of the Bootstrap class whose
name starts with _init are called in declaration
order, each receiving the Yaf_Dispatcher
instance as its only argument.
The Bootstrap class must be named Bootstrap and
extend Yaf_Bootstrap_Abstract. If it is not
already defined, it is loaded from
Bootstrap.php in the application directory; the
application.bootstrap configuration entry overrides
its location.
Parameters
This function has no parameters.
Return Values
Returns the Yaf_Application object itself on
success, or false on failure (for instance if the Bootstrap class
could not be loaded, or if an uncaught exception was thrown by one of
the _init* methods).
Examples
Example #1 A Bootstrap example
<?php
/**
* This file should be under 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 {
public function _initConfig(Yaf_Dispatcher $dispatcher) {
echo "1st called\n";
}
public function _initPlugin(Yaf_Dispatcher $dispatcher) {
echo "2nd called\n";
}
}
?>
Example #2 Yaf_Application::bootstrap() example
<?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();
?>
The above example will output
something similar to: