Yaf_Application::__construct

(Yaf >=1.0.0)

Yaf_Application::__constructYaf_Application锟侥癸拷锟届函锟斤拷

说锟斤拷

publicYaf_Application::__construct ( mixed $config [, string $envrion ] )

锟斤拷始锟斤拷一锟斤拷 Yaf_Application.

锟斤拷锟斤拷

config

锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�, 锟斤拷锟斤拷一锟斤拷指锟斤拷ini锟斤拷式锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷路锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷

锟斤拷锟斤拷锟揭伙拷锟絠ni锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷应锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷yaf.environ 锟斤拷锟斤拷锟矫节★拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟侥拷系摹锟�

Note:

锟斤拷锟斤拷锟绞癸拷锟斤拷锟絠ni锟斤拷锟斤拷锟侥硷拷锟斤拷为锟斤拷应锟斤拷锟斤拷锟矫碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷要锟斤拷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();
?>

锟斤拷锟斤拷锟斤拷锟教碉拷锟斤拷锟斤拷锟斤拷锟斤拷冢锟�

锟轿硷拷