-- holografix . <[email protected]> wrote
(on Thursday, 14 May 2009, 09:01 PM +0100):
> If Bootstrap class has several _init* methods (DB, Session, View/Layout, Auth,
> Acl, etc) but not all of them are required for certain requests, how could one
> avoid their execution ?
Push their initialization into a different location. For instance, you
could create one or more front controller plugins that, based on the
module or controller detected, initialize the session, or the database,
or authentication session, or acls -- and pull configuration from the
bootstrap, via the front controller:
$bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap'));
Alternately, initialization can be done within individual controllers,
pulling the configuration from the bootstrap () in order to get
necessary settings:
$bootstrap = $this->getInvokeArg('bootstrap');
There are a variety of ways to optimize like this; you just have to
figure out where your configuration is, and how to push it down to the
components that need it.
> 2009/5/14 Matthew Weier O'Phinney <[email protected]>
>
> I plan on running some profiling and benchmarks soon. Some ideas off the
> top of my head:
>
> * You'll get much better performance if you create resource methods in
> your bootstrap than if you use resource plugins.
>
> ...
>
> * Only bootstrap what you actually need for *each* request, and defer
> initialization of other resources until they're used. (This is the
> sort of thing that the resource autoloader was intended to help with,
> too.)
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/