Yaf_Application::__construct

(Yaf >=1.0.0)

Yaf_Application::__constructYaf_Application 的构造函数

说明

publicYaf_Application::__construct(mixed$config, string$envrion = ?)

初始化一个 Yaf_Application.

参数

config

关联数组的配置, 或者一个指向 ini 格式的配置文件的路径的字符串。

如果是一个 ini 配置文件,那配置文件中应该有一个定义了 yaf.environ 的配置节。这个在生产环境中是默认的。

注意:

如果你使用了 ini 配置文件作为你应用配置的容器,你需要打开 yaf.cache_config 来提升性能。

And the config entry(and there default value) list blow:

示例 #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.defaultModule=Index ap.dispatcher.defaultController=Index ap.dispatcher.defaultAction=index ;defined modules ap.modules=Index
envrion

Which section will be loaded as the final config

返回值

示例

示例 #2 Yaf_Application::__construct() 示例

<?php
defined
('APPLICATION_PATH') // APPLICATION_PATH will be used in the ini config file
|| define('APPLICATION_PATH', __DIR__));

$application = new Yaf_Application(APPLICATION_PATH.'/conf/application.ini');
$application->bootstrap()->run();
?>

以上示例的输出类似于:

示例 #3 Yaf_Application::__construct() 示例

<?php
$config
= array(
"application" => array(
"directory" => realpath(dirname(__FILE__)) . "/application",
),
);


$application = new Yaf_Application($config);
$application->bootstrap()->run();
?>

以上示例的输出类似于:

To Top