Yaf_Application::bootstrap
PHP Manual
PHP Manual»Yaf_Application»Yaf_Application::bootstrap

Yaf_Application::bootstrap

(Yaf >=1.0.0)

Yaf_Application::bootstrap — Call bootstrap

Descrizione

public function Yaf_Application::bootstrap(): Yaf_Application|false

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.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

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).

Errori/Eccezioni

Triggers a YAF_ERR_TYPE_ERROR error if the found class is not a subclass of Yaf_Bootstrap_Abstract, or an E_WARNING if the bootstrap file or the Bootstrap class cannot be found.

Esempi

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

Il precedente esempio visualizzerà qualcosa simile a:

1st called
2nd called

Vedere anche:

To Top