应用程序配置

应该为 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.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

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

注意:

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

application.ext string

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

application.view.ext string

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

application.modules string

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

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

application.library string

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

注意:

Yaf 2.1.6 以后,该配置项可以是数组。类库的路径将尝试使用 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设置为"/prefix",那么只有"/controller/action"会被当做路由路径。

通常不需要设置此值。

application.dispatcher.throwException bool

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

application.dispatcher.catchException bool

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

application.dispatcher.defaultRoute string

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

application.dispatcher.defaultModule string

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

application.dispatcher.defaultController string

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

application.dispatcher.defaultAction string

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

application.system string

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

注意:

仅有INI_ALL配置项能这样设置

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top