开发者

zend modules models

My application setup wi开发者_高级运维th 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


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/.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜