I am developing a Zend Framework MVC application with some modules, in example, the Users module. There is a model class name “Users_Model_User” that can be used in any module/controller operation. But I need to use an instance of that model in the application Bootstrap class, but there I get an exception:
Fatal error: Class ‘Users_Model_User’ not found in /my/path/…
I have a Bootstrap class for each module:
class Users_Bootstrap extends Zend_Application_Module_Bootstrap {
protected function _initAutoloader() {
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Users_',
'basePath' => APPLICATION_PATH . '/modules/users'
));
return $autoloader;
}
}
and as I said, the modules are working just fine (reciving requests, processing and returning responses). I think this works fine due to the module bootstrap class, that takes care of loading the default module resources, like model classes. But the main Bootstrap class seems to lack of access to the “Users” module model classes.
you could try(not sure it will work)
i don’t think bootstrap is a good place to do mysql queries, you should use a
Zend_Controller_Plugin_Abstract, that way the resources are initiated and the bootstrap autoload is working(i’m using a plugin myself to do queries and check for permissions…)