Stann
Stann

Reputation: 13968

ZEND framework application.ini and bootstrapping

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::getStaticHelper('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....)?

Upvotes: 1

Views: 1693

Answers (1)

Daff
Daff

Reputation: 44215

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).

Upvotes: 4

Related Questions