Application Configuration
You should give an array of config or an ini config file(see Yaf_Config_Ini) path to Yaf_Application::__construct.
You should give an array of config or an ini config file(see Yaf_Config_Ini) path to Yaf_Application::__construct.
Yaf will merge the application configurations and user configurations automatically. The application configurations have prefix "yaf." or "application.". If both "yaf." and "application." exist, "application." will be accepted preferentially.
An PHP array example
<?php
$configs = array(
"application" => array(
"directory" => dirname(__FILE__),
"dispatcher" => array(
"catchException" => 0,
),
"view" => array(
"ext" => "phtml",
),
),
);
$app = new Yaf_Application($configs);
?>An ini file example
[yaf]
yaf.directory = APPLICATION_PATH "/application"
yaf.dispatcher.catchException = 0
[product : yaf]
; user configuration list hereWhen the configuration grows large, Yaf_Config_Ini, which parses the ini file on every request, becomes noticeable overhead. Yaconf parses all ini files under one directory only once at PHP startup and keeps the parsed values in shared memory. Set yaconf.directory to the folder holding the configuration, and pass the returned array to Yaf_Application::__construct:
<?php
// in php.ini: yaconf.directory = /path/to/app/conf
$app = new Yaf_Application(Yaconf::get("application"));
?>A file that contains [section] headers is exposed as one entry per section (inheritance, e.g. [product : yaf], already resolved). Retrieve a single section with a dot, Yaconf::get("application.product"), and pass that array instead; its keys are exactly the merged entries of that section.
| Name | Default | Changelog |
|---|---|---|
| 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 |
Title
application.directorystringThe directory of the application, that is the folder which contains the "controllers", "views", "models", "plugins" folders.
NoteThis config entry is the only one which doesn't has a default value. You should always define it manually.
application.extstringThe file ext of the PHP script, used in class autoloading(
Yaf_Loader).application.view.extstringThe file ext of the view template scripts.
application.modulesstringA comma-separated list of the registered modules, used in the route process, especially while there are more than three segments in the PATH_INFO,
Yaf need a way to find out whether the first segment is a module name or not.
application.librarystringThe local library directory, see
Yaf_Loaderand yaf.library.NoteAfter Yaf 2.1.6, this config entry can be an array. The library path will try to use the items setted in application.library.directory
application.library.directorystringAlias of application.library. Introduced in Yaf 2.1.6
application.library.namespacestringA comma-separated prefix of local library namespace.
Introduced in Yaf 2.1.6
application.bootstrapstringA absolute path of the Bootstrap class script.
application.baseUristringUsed to remove a fixed prefix of request uri in route process. Take a example, comes a request with request uri "/prefix/controller/action". if you set application.baseUri to "/prefix", then only "/controller/action" will take as the PATH_INFO in route process.
In generally, there is no need to set this value.
application.dispatcher.throwExceptionboolIf it set to On, Yaf will throw an exception while some error occurring. See also
Yaf_Dispatcher::throwException.application.dispatcher.catchExceptionboolIf it set to On, Yaf will forward to Error controller/Action while there is an unhandled exception. See also
Yaf_Dispatcher::catchException.application.dispatcher.defaultRoutestringThe default Route, if it is not specificed, Static route will be used as default. See:
Yaf_Router::addRoute.application.dispatcher.defaultModulestringThe default module name, see also
Yaf_Dispatcher::setDefaultModule.application.dispatcher.defaultControllerstringThe default controller name, see also
Yaf_Dispatcher::setDefaultController.application.dispatcher.defaultActionstringThe default action name, see also
Yaf_Dispatcher::setDefaultAction.application.systemstringSet yaf runtime configure in application.ini, like: application.system.lowcase_path
Noteonly those
INI_ALLconfigures can be set in this way