views:

353

answers:

3

My application setup with 2 modules admin and default I test the controller which works fine on modules

but the models doesnt work

I created a model application\modules\admin\models\User.php

<?php

class Admin_Model_User{
}

inside the controller

$user = new Admin_Model_User();

Fatal error: Class 'Admin_Model_User' not found

A: 

Configure an autoloader so that the framework can map your class prefix Admin_Model to the corresponding source path. This is not done automatically.

I suggest reading the part on models of the Zend Framework Quickstart, which explains in detail how to do this.

Ferdinand Beyer
A: 

Are you using an autoloader?

If you do you should change the class name (or path) to reflect the path (or class name)

Models <> Model

You should have

Admin_Model_User in admin/model/user.php

or

Admin_Models_User in admin/models/user.php.

Denis Arh
+1  A: 

Essentially, you need 2 lines in the application.ini file;

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules[] = ""

Then, for each module, you need a module bootstrap file:

File: myproject/application/modules/{modulename}/Bootstrap.php

<?php

class {Modulename}_Bootstrap extends Zend_Application_Module_Bootstrap
{
}

(Yes, it is an empty class.)

Further details are at http://akrabat.com/zend-framework/bootstrapping-modules-in-zf-1-8/.

Rob Allen
I can make non-default model works, but when I create a Default_Model_{Model}, which still get the error , any idea why?I do have Bootstrap.php in my /application/modules/default/
cc96ai