1

I have a Zend project with the following directory structure:

/myApp
  /application
    Bootstrap.php
    /configs
      application.ini
    /layouts
    /modules
      /default
        /controllers
          MessageController.php
          ErrorController.php
          IndexController.php
        /models
          /DbTable
            Message.php
          Message.php
          MessageMapper.php
        /views
        Bootstrap.php
      /login
        /controllers
        /forms
        /library/login
        /models
        /plugins
        /views
        Bootstrap.php
  /data/db
  /library/zend
  /public

http://localhost/ - works fine but i can not get the login module and the message inside the Default module to work. I get the following error:

Fatal error: Class 'Application_Module_Default_Model_MessageMapper' not found in /Library/WebServer/Documents/myApp/application/modules/default/controllers/MessageController.php on line 14

I am sure i am not initialising something i need to. Here is what my code looks like..

application.ini

autoloaderNamespaces[] ="Message_"
autoloaderNamespaces[] ="Login_"
autoloadernamespaces.0 = "Zend_"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.frontController.defaultControllerName = "index"
resources.frontController.defaultActionName = "index"
resources.frontController.params.displayExceptions = 0
resources.frontController.defaultModule = "default"
resources.frontController.params.prefixDefaultModule = "1"
resources.frontController.plugins[] = "Login_Plugin_SecurityCheck"
resources.modules = ""

/application/bootstrap.php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
    protected function _initDoctype()
  {
    $this->bootstrap('view');
    $view = $this->getResource('view');
    $view->doctype('HTML5');
  }
}

/public/index.php

set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));

require_once 'Zend/Application.php';
require_once('Zend/Loader/Autoloader.php');
$autoloader = Zend_Loader_Autoloader::getInstance();

/module/default/controllers/MessageController.php

$message = new Application_Module_Default_Model_MessageMapper();
$this->view->entries = $message->fetchAll();

Let me know if any more details would help. Any help would be much appreciated.

2
  • How is your class defined in MessageMapper.php? Commented Sep 1, 2011 at 16:03
  • I have the following: class Default_Model_MessageMapper It is currently getting stuck on this line of code, which is in a function to fetch all messages from the database: $entry = new Application_Model_Message(); I have tried other combinations like Application_Module_Default_Model_Message(); Still no joy, but commenting these lines makes the page load, so almost there! Commented Sep 1, 2011 at 18:21

3 Answers 3

2

Have you tried:

$message = new Default_Model_MessageMapper(); 

Also, are you autoloading your module in the module Bootstrap.php file? I'm not sure how much it has changed since I used ZF, but I had to include this:

$loader = new Zend_Application_Module_Autoloader(array(   
    'namespace' => 'Default_',
    'basePath'  => '/path/to/modules/default'
));
Sign up to request clarification or add additional context in comments.

3 Comments

Ive added those two points in my code, however i still get an error: Fatal error: Class 'Application_Module_Default_Model_Message' not found in /Library/WebServer/Documents/bollyme/application/modules/default/models/MessageMapper.php on line 56 Line 56 of my code is: $entry = new Application_Module_Default_Model_Message();
You'll need to update that one too then - new Default_Model_Message(); (strip out "Application_Module_" from your class names)
FIXED!It is now working.. both /message and /login - Cheers for all the help! Stripping out Application_Module certainly helped!
0

me too had the same issue, but my cause was very simple

i had a form Form_Template_Add & a controller TemplateController. From the controller i called the form - new Form_Template_Add();

My form resides in a folder template.

Issue was with the folder name, see the 't' in template is small caps, while 'T' for controller & class name is caps. I changes folder name to Template & it worked... hooya

Comments

0

Make sure you have created a Bootstrap.php in each module directory, which looks like:

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{}

In which Admin is the name of the module. Also, make sure there is actually a file Login.php inside directory modules/admin/forms with a class Admin_Form_Login

[Zend_Form][1.11.1] Error Message Fatal error: Class 'Admin_Form_Login' not found in ...\modules\default\controllers\IndexController.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.