Yaf_Application::__construct
(Yaf >=1.0.0)
Yaf_Application::__construct — Yaf_Application constructor
Description
Instance a Yaf_Application.
Parameters
-
config
-
A ini config file path, or a config array
If is a ini config file, there should be a section named as the one defined by yaf.environ, which is "product" by default.
Note:
If you use a ini configuration file as your applicatioin's config container. you would open the yaf.cache_config to improve performance.
And the config entry(and there default value) list blow:
Example #1 A ini config file example
[product] ;this one should alway be defined, and have no default value application.directory=APPLICATION_PATH ;following configs have default value, you may no need to define them application.library = APPLICATION_PATH . "/library" application.dispatcher.throwException=1 application.dispatcher.catchException=1 application.baseUri="" ;the php script ext name ap.ext=php ;the view template ext name ap.view.ext=phtml ap.dispatcher.defaultModuel=Index ap.dispatcher.defaultController=Index ap.dispatcher.defaultAction=index ;defined modules ap.modules=Index
-
envrion
-
Which section will be loaded as the final config
Return Values
Examples
Example #2 Yaf_Application::__construct()example
<?php
defined('APPLICATION_PATH') // APPLICATION_PATH will be used in the ini config file
|| define('APPLICATION_PATH', __DIR__)); //__DIR__ was introduced after PHP 5.3
$application = new Yaf_Application(APPLICATION_PATH.'/conf/application.ini');
$application->bootstrap()->run();
?>
The above example will output something similar to:
Example #3 Yaf_Application::__construct()example
<?php
$config = array(
"application" => array(
"directory" => realpath(dirname(__FILE__)) . "/application",
),
);
/** Yaf_Application */
$application = new Yaf_Application($config);
$application->bootstrap()->run();
?>
The above example will output something similar to:
See Also
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Другие базовые расширения
- Yet Another Framework
- Функция Yaf_Application::app() - Retrieve an Application instance
- Функция Yaf_Application::bootstrap() - Call bootstrap
- Функция Yaf_Application::clearLastError() - Clear the last error info
- Функция Yaf_Application::__clone() - Yaf_Application can not be cloned
- Функция Yaf_Application::__construct() - Yaf_Application constructor
- Функция Yaf_Application::__destruct() - The __destruct purpose
- Функция Yaf_Application::environ() - Retrive environ
- Функция Yaf_Application::execute() - Execute a callback
- Функция Yaf_Application::getAppDirectory() - Get the application directory
- Функция Yaf_Application::getConfig() - Retrive the config instance
- Функция Yaf_Application::getDispatcher() - Get Yaf_Dispatcher instance
- Функция Yaf_Application::getLastErrorMsg() - Get message of the last occurred error
- Функция Yaf_Application::getLastErrorNo() - Get code of last occurred error
- Функция Yaf_Application::getModules() - Get defined module names
- Функция Yaf_Application::run() - Start Yaf_Application
- Функция Yaf_Application::setAppDirectory() - Change the application directory
- Функция Yaf_Application::__sleep() - Yaf_Application can not be serialized
- Функция Yaf_Application::__wakeup() - Yaf_Application can not be unserialized
Коментарии
404 Not Found