2009年4月8日星期三

Re: [fw-mvc] Autoloading module resources with 1.8 Preview

Thanks, I guess will work (still got one error, below)

What settings for frontController resource are recommended for a modular structure ? In testing projects i used:

resources.frontcontroller.moduledirectory = MODULE_PATH
resources.frontcontroller.defaultmodule = "default"

Now, since 1.8 Previe I am getting a new error:

Fatal error: Uncaught exception 'Zend_Controller_Exception' with message 'No default module defined for this application'

I tried couple of combinations for  settings, even those from http://framework.zend.com/manual/en/zend.application.available-resources.html

But still no luck...
--  Best regards, Cristian Bichis www.zftutorials.com | www.zfforums.com | www.zftalk.com | www.zflinks.com

-- Cristian Bichis <contact@zftutorials.com> wrote (on Wednesday, 08 April 2009, 10:36 PM +0300):   
Ok, so it's not possible to auto-load modules resources without making a   bootstrap for each of modules ?     
 You can, but you have to do it yourself by creating a resource method or plugin. As an example:       class Bootstrap extends Zend_Application_Bootstrap_Base     {         protected $_modules = array(             'Blog' => APPLICATION_PATH . '/modules/blog',             'News' => APPLICATION_PATH . '/modules/news',         );          protected function _initModuleAutoloaders()         {             foreach ($this->_modules as $namespace => $path) {                 $loader = new Zend_Application_Module_Autoloader(array(                     'namespace' => $namespace,                     'basePath'  => $path,                 ));             }         }          // ...     }  That will create the autoloader for the modules you list; instantiation registers with the main autoloader instance implicitly.    
Two things:   * First, extend Zend_Application_Module_Bootstrap in your module    bootstraps. Part of instantiation includes registering a module    autoloader for that module.   * Second, use the Modules resource plugin with your application    bootstrap. This will search through your module directories for    bootstraps and initialize them if found.  I'll be getting a full example up soon to make this more clear.       
   


没有评论: