|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Autoloading modulesI have read some autoloading articles here, but all examples are with no or one module. My application has this structure (almost everything is inside a module): /configs /layouts /modules /default /admin /blog /calendar with-1.8-Preview-td22956945.html. It does not end with a conclusion and the documentation is not clear about the Zend_Application_Module_Loader. by scanning the application/modules directory. The thread mentioned above has another approach: each module contains its own bootstrap with config. Are there any advices about this rather new subject (the manual seems even unfinished)? Jurian |
|
|
Re: Autoloading modules-- Jurian Sluiman <subscribe@...> wrote
(on Monday, 04 May 2009, 02:20 PM +0200): > I have read some autoloading articles here, but all examples are with no or > one module. My application has this structure (almost everything is inside a > module): > > > /application > /configs > /layouts > /modules > /default > /admin > /blog > /calendar > > > I have read this thread: http://www.nabble.com/Autoloading-module-resources- > with-1.8-Preview-td22956945.html. It does not end with a conclusion and the > documentation is not clear about the Zend_Application_Module_Loader. > > How can I autoload all my modules? I can create for each module an autoloader > by scanning the application/modules directory. The thread mentioned above has > another approach: each module contains its own bootstrap with config. Are > there any advices about this rather new subject (the manual seems even > unfinished)? In each module, create a bootstrap that extends Zend_Application_Module_Bootstrap, with the class name <Modulename>_Bootstrap. That will setup an autoloader using Zend_Application_Module_Autoloader for that module which follows the recommended directory structure guidelines. If you need additional configuration per-module, then you're all setup to do so; otherwise, that's all you need. -- Matthew Weier O'Phinney Project Lead | matthew@... Zend Framework | http://framework.zend.com/ |
|
|
Re: Autoloading modules> -- Jurian Sluiman <subscribe@...> wrote > > (on Monday, 04 May 2009, 02:20 PM +0200): > > I have read some autoloading articles here, but all examples are with no > > or one module. My application has this structure (almost everything is > > inside a module): > > > > > > /application > > /configs > > /layouts > > /modules > > /default > > /admin > > /blog > > /calendar > > > > > > I have read this thread: > > http://www.nabble.com/Autoloading-module-resources- > > with-1.8-Preview-td22956945.html. It does not end with a conclusion and > > the documentation is not clear about the Zend_Application_Module_Loader. > > > > How can I autoload all my modules? I can create for each module an > > autoloader by scanning the application/modules directory. The thread > > mentioned above has another approach: each module contains its own > > bootstrap with config. Are there any advices about this rather new > > subject (the manual seems even unfinished)? > > In each module, create a bootstrap that extends > Zend_Application_Module_Bootstrap, with the class name > <Modulename>_Bootstrap. That will setup an autoloader using > Zend_Application_Module_Autoloader for that module which follows the > recommended directory structure guidelines. > > If you need additional configuration per-module, then you're all setup > to do so; otherwise, that's all you need. In the global bootstrap I have added the application/module directory as a module directory (I had that already). |
|
|
Re: Autoloading modules
Same problem for me here. It seems that autoloading works nice for all modules, except the default one. So the same code (in frontcontroller plugin) works fine $initProcedure = new Modulename_Model_Initialize(); unless i make 'Modulename' my default module in application config. I wonder what's wrong with that (or nothing maybe :) but it's quite unclear what is actually happening. Dmitry. |
|
|
Re: Autoloading modulesHello,
There is some more on the topic i discovered after tweaking it around: the problem seems to be because of default module actually being 'default' that makes Zend MVC treat it like an ordinary application folder and NOT like a module folder. That's the reason why module's Bootstrap is ignored and global application Bootstrap is used. In other words your global application bootstrap must be under your default module folder. It seems a little strange to me, as i would prefer all my modules be treated the same way and have application Bootstrap hold al common things for all the application and module Bootstraps handle module-dependent configurations. I found some topics here on the list addressing similar problem but no practical solution still. I found two ways of handling such cases but they both just don't seem right to me and appear to be a little hacky. So the first one is to create special _initAutoloader() method in global Bootstrap specially for the default module (with module name as a namspace): protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Modulename', 'basePath' => APPLICATION_PATH . '/modules/modulename' )); return $autoloader; } I don't like the idea of treating my default module in 'special' way, i would rather prefer it treated regularly like all the other modules. But still it allows autoloading default module's resources. The other approach is to tweak application config and point my controlerDirectory to default module's controllers directory and do not specify default module at all. # controllers resources.frontController.controllerDirectory = APPLICATION_PATH "/modules/modulename/controllers" resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" #resources.frontController.defaultModule = "modulename" <-- remove this This allows to use both global application Bootstrap and default Module's bootstrap BUT seems to be a very much a hack. So there's a lot of confusion here fore me and i would appreciate if someone could make this more clear. Thank you. Dmitry. |
| Free embeddable forum powered by Nabble | Forum Help |