Issue Type: Improvement Created: 2009-05-15T19:41:53.000+0000 Last Updated: 2009-08-21T16:42:08.000+0000 Status: Resolved Fix version(s): Reporter: Tomoaki Kosugi (noopable) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Application
Related issues: Attachments:
Zend_Application is very useful as resource management. And I remade my modules with some custom plugin-resource(s). Some resources are required for inter-module ex. routes , but others are optional . Some optional resources may have expensive cost to initialize, ex. loading config from DB. And I have many modules in the system. Each module will have many resources for themselves. Usually, all resources will be booted in application's bootstrap process. It is ineffective things for some of the people, like me.
How about a plan to add a startupResources option to Zend_Application. It features an ordering starup resources and lazy load. Simply put, - If the _bootstrap method will be called without argment, it executes startup-resources in order. - A method "getResource" must be able to initialize a resource on-demand.
Change target is Zend_Application_Bootstrap_BootstrapAbstract::_bootstrap , getResources, adding setStartupResources
Posted by Piotr Czachur (zimnyx) on 2009-05-28T05:34:29.000+0000
I agree, loading plugin resources on demand would be great enhancement.
Posted by blinky (blinky1ar) on 2009-08-07T22:47:03.000+0000
Hi check this post Initializing only one module per request in Zend_Framework at easytech blog This guys write some code to load only the resources for the module that is being called.
Posted by Matthew Weier O'Phinney (matthew) on 2009-08-21T12:59:03.000+0000
If you have resources that need to be loaded only if a given module is selected, the appropriate place to do this is in a front controller plugin.
Zend_Application was designed to ease the burden of bootstrapping. One common issue encountered by developers was that they had configuration for modules that needed to be performed on each request: loading of module-specific routes (so that they can be matched against) and setting up autoloading for module resources. These activities could not be done easily prior to the introduction of Zend_Application.
However, all along, if you've had resources that were module-specific and should only be run if the given module were selected, the appropriate time to load those was within a front controller plugin hook. As an example, if you don't need to initialize a DB for a given module unless that module will be used, do it during a preDispatch() hook in a Zend_Controller_Plugin -- and register the plugin as part of your module bootstrap.
Posted by Tomoaki Kosugi (noopable) on 2009-08-21T16:42:08.000+0000
Thanks a lot for an articulate way.
Have you found an issue?
See the Overview section for more details.