ZF-6685: add startupResources option for lazy load resources

Description

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

Comments

I agree, loading plugin resources on demand would be great enhancement.

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.

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.

Thanks a lot for an articulate way.