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 �����ýڡ������������������Ĭ�ϵġ�

Note:

�����ʹ����ini�����ļ���Ϊ��Ӧ�����õ�����������Ҫ��yaf.cache_config ���������ܡ�

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

����ֵ

����

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();
?>

�������̵���������ڣ�

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();
?>

�������̵���������ڣ�

�μ�