Application Configuration
You should give an array of config or an ini config file(see Yaf_Config_Ini) path to Yaf_Application::__construct().
Yaf configurations could be merged with user configurations. The difference is, Yaf configurations are prefixed with "yaf." or "application.", if there are both "yaf." and "application.", "application." will be used.
Example #1 An array of yaf configuration example
<?php
$configs = array(
"application" => array(
"directory" => dirname(__FILE__),
"dispatcher" => array(
"catchException" => 0,
),
"view" => array(
"ext" => "phtml",
),
),
);
$app = new Yaf_Application($config);
?>
Example #2 an ini file of yaf configuration example
[yaf] yaf.directory = APPLICATION_PATH "/appliation" yaf.dispatcher.catchException = 0 [product : yaf] ; user configuration list here
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 |
Here's a short explanation of the configuration directives.
-
application.directory
string -
The directory of the application, that is the folder which contains the "controllers", "views", "models", "plugins" folders.
Note:
This config entry is the only one which doesn't has a default value, which means you should always define it.
-
application.ext
string -
The file ext of the PHP script, used in class autoloading( Yaf_Loader).
-
application.view.ext
string -
The file ext of the view template script.
-
application.modules
string -
A 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.library
string -
The local library directory, see Yaf_Loader and yaf.library.
Note:
As of Yaf 2.1.6, this config entry can also be a array, when it is array, then the library path will try to use the value of application.library.directory
-
application.library.directory
string -
Alias of application.library. Introduced in Yaf 2.1.6
-
application.library.namespace
string -
A comma-separated prefix of local library namespace.
Introduced in Yaf 2.1.6
-
application.bootstrap
string -
A absolute path of the Bootstrap class script.
-
application.baseUri
string -
Used 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, you have no need to set this value.
-
application.dispatcher.throwException
bool -
If this is On, Yaf will throw exception while some error occurring. see also Yaf_Dispatcher::throwException().
-
application.dispatcher.catchException
bool -
If this is On, Yaf will forward to Error controller, Error Action while there is a uncaught exception. see also Yaf_Dispatcher::catchException().
-
application.dispatcher.defaultRoute
string -
The default Route, if it is not specificed, Static route will be used as default route, see: Yaf_Router::addRoute().
-
application.dispatcher.defaultModule
string -
The default module name, see also Yaf_Dispatcher::setDefaultModule().
-
application.dispatcher.defaultController
string -
The default controller name, see also Yaf_Dispatcher::setDefaultController().
-
application.dispatcher.defaultAction
string -
The default action name, see also Yaf_Dispatcher::setDefaultAction().
-
application.system
string -
Set yaf runtime configure in application.ini, like: application.system.lowcase_path
Note:
only those PHP_INI_ALL configures can be set in this way
- Введение
- Установка и настройка
- Предопределенные константы
- Примеры
- Application Configuration
- The Yaf_Application class
- The Yaf_Bootstrap_Abstract class
- The Yaf_Dispatcher class
- The Yaf_Config_Abstract class
- The Yaf_Config_Ini class
- The Yaf_Config_Simple class
- The Yaf_Controller_Abstract class
- The Yaf_Action_Abstract class
- The Yaf_View_Interface class
- The Yaf_View_Simple class
- The Yaf_Loader class
- The Yaf_Plugin_Abstract class
- The Yaf_Registry class
- The Yaf_Request_Abstract class
- The Yaf_Request_Http class
- The Yaf_Request_Simple class
- The Yaf_Response_Abstract class
- The Yaf_Route_Interface class
- The Yaf_Route_Map class
- The Yaf_Route_Regex class
- The Yaf_Route_Rewrite class
- The Yaf_Router class
- The Yaf_Route_Simple class
- The Yaf_Route_Static class
- The Yaf_Route_Supervar class
- The Yaf_Session class
- The Yaf_Exception class
- The Yaf_Exception_TypeError class
- The Yaf_Exception_StartupError class
- The Yaf_Exception_DispatchFailed class
- The Yaf_Exception_RouterFailed class
- The Yaf_Exception_LoadFailed class
- The Yaf_Exception_LoadFailed_Module class
- The Yaf_Exception_LoadFailed_Controller class
- The Yaf_Exception_LoadFailed_Action class
- The Yaf_Exception_LoadFailed_View class
Коментарии
$app = new Yaf_Application($config)=>$app = new Yaf_Application($configs);