Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: Zend_Application
-
Labels:None
Description
As defined in the section 4.6.4 of reference guide, the Modules resource (Zend_Application_Resource_Modules), by design creates a modular resource autoloader (Zend_Application_Modules_Autoloader) automatically. A deeper look in the components code shows that the Zend_Application_Module_Bootstrap have a property ($_resourceLoader) that define a resource autoloader (Zend_Application_Module_Autoloader). Chasing the calls stack:
- Zend_Application_Module_Bootstrap calls initResourceLoader() that proxies to getResourceLoader();
- getResourceLoader() creates a new Zend_Application_Module_Autoloader object;
- Zend_Application_Module_Autoloader constructor calls it's parent (Zend_Loader_Autoloader_Resource) constructor and pass the same options received from Zend_Application_Module_Bootstrap getResourceLoader() call;
- After that, the Zend_Application_Module_Autoload initDefaultResourceTypes() method is called, which initialize autoloading specifications - as plugins, models, etc.
Although this looks nice, when using a module bootstrap (a Admin_Bootstrap extends Zend_Application_Module_Bootstrap), the module resource autoloader doesn't seems to be properly initialized - it's not possible to load, for example, models without having to define a autoloader within a resource method or plugin.
I only got modular bootstrapping working by:
- Specifying a Zend_Application_Bootstrap_Bootstrap bootstrap object for the default module - it doesn't work with a Zend_Application_Module_Bootstrap;
- Specifying a resource autoloader as resource method in the default module bootstrap;
- Specifying a Zend_Application_Module_Bootstrap bootstrap object for non default modules.
I think that using Zend_Application_Module_Bootstrap should be mandatory for modular bootstrapping - and have the resource autoloader working as well. This can be a simple approach to avoid the current complexity of modular bootstrapping.
Last but not least, the section in reference guide looks very poor for a subject like modular bootstrapping and is insufficient to have a modular application working at a glance.
It took me quite some time to understand exactly what you were trying to explain, which was quite simply: extending Zend_Application_Module_Bootstrap in the default module does not work as expected.
There are some workarounds/strategies you can use now to have this work. The easiest is to:
application/ modules/ default/ blog/ news/This strategy utilizes modules appropriately. Because the module bootstrap is now in a directory named after the module, the module namespace will be set properly (to "Default_"), which will allow the various resources to load under that namespace.
We plan to make this easier for 1.10 already, but have to be careful to ensure we do not create a BC break.
- Put all modules, including the default module, under a "modules" directory:
- Tell Zend_Application where to find the default module's bootstrap, and what it's named:
- Have Default_Bootstrap extend Zend_Application_Module_Bootstrap
This strategy utilizes modules appropriately. Because the module bootstrap is now in a directory named after the module, the module namespace will be set properly (to "Default_"), which will allow the various resources to load under that namespace.
We plan to make this easier for 1.10 already, but have to be careful to ensure we do not create a BC break.application/ modules/ default/ blog/ news/