-- Sergio Rinaudo <kaiohken1...@hotmail.com> wrote
(on Thursday, 07 May 2009, 01:15 PM +0200):
> I need to load from bootstrap some resources located in my 'models' directory.
> But if I try I get
> 
> Fatal error: Class '{model}' not found in [....]\application\Bootstrap.php on
> line 201
> 
> What to do to include resources located in models dir?
> 
> I notice there is a class Zend_Application_Module_Autoloader ( maybe ) for 
> this
> purpose, I tried to use it without success

I'd create a resource method in your bootstrap that defines the resource
autoloader:

    class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
    {
        protected function _initAutoloader()
        {
            $loader = new Zend_Application_Module_Autoloader(array(
                'namespace' => 'Default',
                'basePath'  => APPLICATION_PATH,
            ));
        }
    }

The above sets up autoloading for the default module, with a namespace
of 'Default'. Models will then need a class prefix of 'Default_Model_'.

Then, in methods where you need to load from models, add the above
method as a dependency:

    $this->bootstrap('autoloader');

-- 
Matthew Weier O'Phinney
Project Lead            | matt...@zend.com
Zend Framework          | http://framework.zend.com/

Reply via email to