应用程序配置

应该为 Yaf_Application::__construct() 提供配置数组或者 ini 配置文件(参阅 Yaf_Config_Ini)路径。

Yaf 将会自动合并应用程序配置和用户配置。应用程序配置有前缀“yaf.”或“application.”。如果“yaf.”和“application.”同时存在,将会优先接受“application.”。

示例 #1 PHP 数组示例

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

示例 #2 ini 文件示例

[yaf] yaf.directory = APPLICATION_PATH "/appliation" yaf.dispatcher.catchException = 0 [product : yaf] ; user configuration list here

Yaf 应用程序配置
名字默认更新日志
application.directory 
application.ext"php"
application.view.ext"phtml"
application.modules"index"
application.libraryapplication.directory . "/library"
application.library.directoryapplication.directory . "/library"
application.library.namespace""
application.bootstrapapplication.directory . "/Bootstrap" . application.ext
application.baseUri""
application.dispatcher.defaultRoute 
application.dispatcher.throwException1
application.dispatcher.catchException0
application.dispatcher.defaultModule"index"
application.dispatcher.defaultController"index"
application.dispatcher.defaultAction"index"
application.system 

这是配置指令的简短说明。

application.directorystring

应用程序的目录,文件夹包含“controllers”、“views”、“models”、“plugins”。

注意:

此为唯一没有默认值的配置条目,应该始终手动定义它。

application.extstring

PHP 脚本的扩展名,类的自动加载需要(Yaf_Loader)。

application.view.extstring

视图模板脚本的文件扩展名。

application.modulesstring

注册的模块列表,以逗号分隔,用于路由处理,特别是当PATH_INFO超过三段的时候,

Yaf需要用它来判断第一段是否是一个模块。

application.librarystring

本地类库的目录,参见 Yaf_Loaderyaf.library

注意:

Yaf 2.1.6 以后,该配置项可以是数组。类库的路径将尝试使用 application.library.directory 中设置的条目。

application.library.directorystring

Alias of application.library. Introduced in Yaf 2.1.6

application.library.namespacestring

逗号分隔的本地类库命名空间前缀。

Yaf2.1.6以后加入

application.bootstrapstring

Bootstrap类脚本文件的绝对路径。

application.baseUristring

路由处理中需要忽略的路径前缀。举个例子,请求"/prefix/controller/action"时。如果你将application.baseUri设置为"/prefix",那么只有"/controller/action"会被当做路由路径。

通常不需要设置此值。

application.dispatcher.throwExceptionbool

如果设置为 On,Yaf 会在发生错误的地方抛出异常。参见 Yaf_Dispatcher::throwException()

application.dispatcher.catchExceptionbool

如果设置为 On,当在存在未处理的异常时,Yaf 将转发到 Error controller/Action。参见 Yaf_Dispatcher::catchException()

application.dispatcher.defaultRoutestring

默认路由,如果未指定,默认使用静态路由。参见 Yaf_Router::addRoute()

application.dispatcher.defaultModulestring

默认模块名,参见 Yaf_Dispatcher::setDefaultModule()

application.dispatcher.defaultControllerstring

默认控制器名,参见 Yaf_Dispatcher::setDefaultController()

application.dispatcher.defaultActionstring

默认动作名,参见 Yaf_Dispatcher::setDefaultAction()

application.systemstring

在application.ini中设置Yaf运行时配置,如: application.system.lowcase_path

注意:

仅有INI_ALL配置项能这样设置

To Top