(Yaf >=1.0.0)
Yaf_Application::__construct — Yaf_Application constructor
Instantiate a Yaf_Application. The constructor also initializes the singleton application, the Yaf_Loader and the Yaf_Dispatcher, so it must be called before any of those are used.
configAn INI configuration file path, or a configuration array.
If it is an INI configuration file, there should be a section named
as the one defined by
yaf.environ, which is
"product" by default.
The application configuration entries (and their default values) are documented in Application Configuration:
Example #1 An ini config file example
[product] ;this one should always be defined, and has no default value application.directory=APPLICATION_PATH ;following configs have default values, you may not need to define them application.library = APPLICATION_PATH . "/library" application.dispatcher.throwException=1 application.dispatcher.catchException=1 application.baseUri="" ;the php script ext name application.ext=php ;the view template ext name application.view.ext=phtml application.dispatcher.defaultModule=Index application.dispatcher.defaultController=Index application.dispatcher.defaultAction=index ;defined modules application.modules=Index
environWhich section will be loaded as the final configuration. If it is not given, the value of the yaf.environ directive is used.
Throws a Yaf_Exception_StartupError exception
(or triggers a YAF_ERR_STARTUP_FAILED error, when
Yaf_Dispatcher::throwException() is off) if a
Yaf_Application has already been instantiated,
or if the configuration is invalid.
Example #2 Yaf_Application::__construct() 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()->run();
?>Example #3 Yaf_Application::__construct() example
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)) . "/application",
),
);
/** Yaf_Application */
$application = new Yaf_Application($config);
$application->bootstrap()->run();
?>