开发者

ZEND framework application.ini and bootstrapping

开发者 https://www.devze.com 2023-02-01 16:59 出处:网络
I am confused about different ways to bootstrap ZF: for example I can do this in application.ini: resources.view.encoding = \"UTF-8\"

I am confused about different ways to bootstrap ZF: for example I can do this in application.ini:

resources.view.encoding = "UTF-8"

and then I can do virtually the same? in bootstrap.php file:

protected function _initView(){
$view = new Zend_View();       
$view->setEncoding('UTF-8');
$viewRenderer =Zend_Controller_Action_HelperBroker::get开发者_开发问答StaticHelper('ViewRenderer');
$viewRenderer->setView($view);
return $view;
}

1) Are these methods virtually the same? or they work differently in the background?


2) Is there a reason to choose one over the other (I assume there's gotta be....)?


The application.ini uses the Resource Plugins whereas the bootstrap class initializes plain objects. I see the advantage of resource loaders vs. an application/module specific bootstrap class in reusability.

If your bootstrap classes always look the same you might want to consider writing a resource loader that does it. It is also easier and more user friendly to configure (and you can mix both approaches, too).

0

精彩评论

暂无评论...
验证码 换一张
取 消