(Yaf >=1.0.0)
Yaf_Application::__construct — Yaf_Application 建構子
config
一個 ini 設定檔路徑,或是一個設定陣列
如果是 ini 設定檔,則應該有一個以 `yaf.environ` 定義的名稱為名稱的區段,預設為 "product"。
注意事項:
如果您使用 ini 設定檔作為應用程式的設定容器,您應該開啟 `yaf.cache_config` 來提升效能。
以下列出設定項目(及其預設值)
範例 #1 一個 ini 設定檔範例
[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.defaultModule=Index ap.dispatcher.defaultController=Index ap.dispatcher.defaultAction=index ;defined modules ap.modules=Index
環境
哪個區段將會被載入作為最終設定
範例 #2 Yaf_Application::__construct() 範例
<?php
defined('APPLICATION_PATH') // APPLICATION_PATH 將會在 ini 設定檔中使用
|| define('APPLICATION_PATH', __DIR__));
$application = new Yaf_Application(APPLICATION_PATH.'/conf/application.ini');
$application->bootstrap()->run();
?>
上述範例將會輸出類似以下的內容
範例 #3 Yaf_Application::__construct() 範例
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)) . "/application",
),
);
/** Yaf_Application */
$application = new Yaf_Application($config);
$application->bootstrap()->run();
?>
上述範例將會輸出類似以下的內容