(Yaf >=1.0.0)
Yaf_Application::__construct — Yaf_Application的構(gòu)造函數(shù)
初始化一個(gè) Yaf_Application.
config
關(guān)聯(lián)數(shù)組的配置, 或者一個(gè)指向ini格式的配置文件的路徑的字符串。
如果是一個(gè)ini配置文件,那配置文件中應(yīng)該有一個(gè)定義了yaf.environ 的配置節(jié)。這個(gè)在生產(chǎn)環(huán)境中是默認(rèn)的。
注意:
如果你使用了ini配置文件作為你應(yīng)用配置的容器,你需要打開yaf.cache_config 來提升性能。
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
envrion
Which section will be loaded as the final config
示例 #2 Yaf_Application::__construct()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()->run();
?>
以上例程的輸出類似于:
示例 #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();
?>
以上例程的輸出類似于: