Take the 2-minute tour ×

I want to initialize model object inside the controller, but fatal error occurs.

Fatal error: Class 'Visits_Model_Visit' not found in C:\AppServ\www\zendApps\InspectionSys\application\modules\visits\controllers\VisitController.php on line 24

I am sing module call visits, It have it's structure of Model, View and controller folders.

The Visits_Model_Visit exists inside the model folder and I am trying to define object from it inside an action of the controller

public function addAction() {

    if (isset($_POST)) {

        $visitObj = new Visits_Model_Visit();   // an error occur here!


Here is the structure of the peoject

share|improve this question
What's your project directory structure? Where's located your model? What's your model class filename? –  Liyali Mar 4 '12 at 11:56
I'll upload it, just a second –  palAlaa Mar 4 '12 at 11:58
Do you have those lines in your application.ini? resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" resources.frontController.params.prefixDefaultModule = "1" resources.modules[] = –  dextervip Mar 5 '12 at 2:41
I have this problem sometimes with specific projects, I never found a good solution and tend to just avoid the problem by using the application level models. I know this doesn't help, but at least know you're not alone :) –  RockyFord Mar 5 '12 at 3:37

2 Answers 2

up vote 1 down vote accepted

[edit] I found it... look at your Bootstrap.php that is under /modules and move it under /modules/visits and make sure it looks like below, that should fix it.

All I can say is to check a few things, normally everything will work when your module bootstrap looks like:


class Visits_Bootstrap extends Zend_Application_Module_Bootstrap{
    //put your code here

and your application.ini has these lines:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.frontController.params.prefixDefaultModule = ""
resources.modules = ""

This is my whole frontcontroller section and I do have access to my module level models. I know of no other settings to make modules work, although I'm sure there are many variations.

share|improve this answer

Your Visits_Model_Visit exists in the /models folder (note the 's' on the end), firstly watch out for this...but I don't know how you set up your autoloader.

share|improve this answer
This would be correct in ZF 1.x as /models is a default route and will map to Module_Model_XXX. –  RockyFord Mar 5 '12 at 3:33

Your Answer


