How to access models in default module in Zend_Framework?

445 views Asked by At

I'm trying to make my application modular using modules in Zend Framework.

Here is my new project structure:

   configs/ 
        application.ini
    layouts/
        filters/
        helpers/
        scripts/
    modules/
        default/
               forms/
               controllers/
               models/
               views/
        admin/
               forms/
               controllers/
               models/
               views/
    Bootstrap.php

I've added these lines in my application .ini:

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.params.prefixDefaultModule = false
resources.modules[] =

I can now access the controllers and views in the default directory without changing anything in my previous configuration (I just moved my controllers/models/views into the module/ directory).

However, I can't access to models located in the default module.

Here is the error displayed when I tried to access to this model from a controller:

Fatal error: Class 'Model_Account_Edit' not found in /var/www/.../application/modules/default/controllers/AccountController.php on line 138

Any idea?

1

There are 1 answers

0
Ilians On BEST ANSWER

It's probably because you're missing a module specific bootstrap. Add a bootstrap file to each module and it should work. The class should look something like this:

class Default_Bootstrap extends Zend_Application_Module_Bootstrap{}

Add it to the project

modules/
    default/
           forms/
           controllers/
           models/
           views/
           Bootstrap.php

And you should be ready to go.