Yaf_Application constructor

(Yaf >=1.0.0)

Yaf_Application::__constructYaf_Application constructor


publicYaf_Application::__construct ( mixed $config [, string $envrion ] )

Instance a Yaf_Application.

Список параметров


A ini config file path, or a config array

If is a ini config file, there should be a section named as the one defined by yaf.environ, which is "product" by default.


If you use a ini configuration file as your applicatioin's config container. you would open the yaf.cache_config to improve performance.

And the config entry(and there default value) list blow:

Пример #1 A ini config file example

[product] ;this one should alway be defined, and have no default value application.directory=APPLICATION_PATH  ;following configs have default value, you may no need to define them application.library = APPLICATION_PATH . "/library" application.dispatcher.throwException=1 application.dispatcher.catchException=1  application.baseUri=""  ;the php script ext name ap.ext=php  ;the view template ext name ap.view.ext=phtml  ap.dispatcher.defaultModuel=Index ap.dispatcher.defaultController=Index ap.dispatcher.defaultAction=index  ;defined modules ap.modules=Index


Which section will be loaded as the final config

Возвращаемые значения


Пример #2 Yaf_Application::__construct()example

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

Результатом выполнения данного примера будет что-то подобное:


Пример #3 Yaf_Application::__construct()example

= array(
"application" => array(
"directory" => realpath(dirname(__FILE__)) . "/application",

/** Yaf_Application */
$application = new Yaf_Application($config);

Результатом выполнения данного примера будет что-то подобное:


Смотрите также