我有一个 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/ - 工作正常,但我无法让登录模块和默认模块内的消息正常工作。我收到以下错误:
致命错误:在第 14 行的 /Library/WebServer/Documents/myApp/application/modules/default/controllers/MessageController.php 中找不到类“Application_Module_Default_Model_MessageMapper”
我确定我没有初始化我需要的东西。这是我的代码的样子..
应用程序.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();
让我知道是否有更多细节会有所帮助。任何帮助将非常感激。