Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zend modules models

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

like image 890
cc96ai Avatar asked May 13 '26 07:05

cc96ai


2 Answers

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

like image 154
Rob Allen Avatar answered May 16 '26 01:05

Rob Allen


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.

like image 24
Ferdinand Beyer Avatar answered May 16 '26 00:05

Ferdinand Beyer