我有以下目錄結構一個Zend項目:PHP/Zend的:致命錯誤 - 找不到課程
/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/ - 工作正常,但我不能讓默認模塊內部的登錄模塊和消息上班。我得到以下錯誤:
致命錯誤:類「Application_Module_Default_Model_MessageMapper」在/Library/WebServer/Documents/myApp/application/modules/default/controllers/MessageController.php沒有發現第14行
我當然,我不是在初始化我需要的東西。這裏是我的代碼看起來像..
的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();
讓我知道是否有更多的細節會有所幫助。任何幫助將非常感激。
如何在'MessageMapper.php'定義你的課嗎? – ChrisA
我有以下幾點: '類Default_Model_MessageMapper' 它目前陷入在此行的代碼,這是一個函數從數據庫中獲取的所有消息: '$ =進入新Application_Model_Message();' 我嘗試過其他組合,例如'Application_Module_Default_Model_Message();' 仍然沒有快樂,但評論這些行使頁面加載,所以幾乎在那裏! – TLD