應(yīng)用配置

你需要傳遞一個config數(shù)組或ini配置文件(參見 Yaf_Config_Ini) 給 Yaf_Application::__construct().

Yaf的配置文件會和用戶的配置文件合并。區(qū)別在于,Yaf的配置文件是以"yaf."或"application."開頭,如果兩項都存在,則"application."生效。

示例 #1 config為數(shù)組的例子

<?php
    $configs 
= array(
            
"application" => array(
                
"directory" => dirname(__FILE__),
                
"dispatcher" => array(
                      
"catchException" => 0,
                    ),
                
"view" => array(
                       
"ext" => "phtml",
                    ),
                ),
           );
    
$app = new Yaf_Application($config);
?>

示例 #2 config為ini文件的例子

[yaf]
yaf.directory = APPLICATION_PATH "/appliation"
yaf.dispatcher.catchException = 0

[product : yaf]
; user configuration list here

Yaf Application Config
名字 默認(rèn) 更新日志
application.directory  
application.ext "php"
application.view.ext "phtml"
application.modules "index"
application.library application.directory . "/library"
application.library.directory application.directory . "/library"
application.library.namespace ""
application.bootstrap application.directory . "/Bootstrap" . application.ext
application.baseUri ""
application.dispatcher.defaultRoute  
application.dispatcher.throwException 1
application.dispatcher.catchException 0
application.dispatcher.defaultModule "index"
application.dispatcher.defaultController "index"
application.dispatcher.defaultAction "index"
application.system  

這是配置指令的簡短說明。

application.directory string

應(yīng)用程序的目錄,包含"controllers", "views", "models", "plugins"等子目錄。

注意:

這是唯一一個沒有默認(rèn)值的配置項,你需要手動指定它。

application.ext string

PHP腳本的擴(kuò)展名,類的自動加載需要用到它( Yaf_Loader)。

application.view.ext string

視圖模板擴(kuò)展名。

application.modules string

注冊的模塊列表,以逗號分隔,用于路由處理,特別是當(dāng)PATH_INFO超過三段的時候,

Yaf需要用它來判斷第一段是否是一個模塊。

application.library string

本地類庫的目錄,參見Yaf_Loaderyaf.library。

注意:

Yaf2.1.6以后,該配置項也可以是一個數(shù)組,當(dāng)它是數(shù)組的時候,類庫的路徑將嘗試使用application.library.directory的值。

application.library.directory string

Alias of application.library. Introduced in Yaf 2.1.6

application.library.namespace string

逗號分隔的本地類庫命名空間前綴。

Yaf2.1.6以后加入

application.bootstrap string

Bootstrap類腳本文件的絕對路徑。

application.baseUri string

路由處理中需要忽略的路徑前綴。舉個例子,請求"/prefix/controller/action"時。如果你將application.baseUri設(shè)置為"/prefix",那么只有"/controller/action"會被當(dāng)做路由路徑。

通常不需要設(shè)置此值。

application.dispatcher.throwException bool

開啟此項,Yaf會在發(fā)生錯誤的地方拋出異常。參見 Yaf_Dispatcher::throwException()

application.dispatcher.catchException bool

開啟此項,如果有未捕獲的異常,Yaf將會把它定向到Error controller, Error Action。參見 Yaf_Dispatcher::catchException()

application.dispatcher.defaultRoute string

默認(rèn)路由,如果未指定,靜態(tài)路由會被當(dāng)做是默認(rèn)路由,參見: Yaf_Router::addRoute()。

application.dispatcher.defaultModule string

默認(rèn)模塊名,參見 Yaf_Dispatcher::setDefaultModule()。

application.dispatcher.defaultController string

默認(rèn)控制器名,參見 Yaf_Dispatcher::setDefaultController()。

application.dispatcher.defaultAction string

默認(rèn)動作名,參見 Yaf_Dispatcher::setDefaultAction()

application.system string

在application.ini中設(shè)置Yaf運(yùn)行時配置,如: application.system.lowcase_path

注意:

僅有PHP_INI_ALL配置項能這樣設(shè)置