我想做一个Zend具有以下结构的应用程序:
-SITE
---- application
---- configs
---- layouts
---- modules
-------- default
------------ controllers
------------ forms
------------ models
------------ views
------------ Bootstrap.php
-------- admin
------------ controllers
------------ forms
------------ models
------------ views
------------ Bootstrap.php
---- Bootstrap.php
-- public
-- library
------My
---------Controller
-----------Plugin
-------------ModuleDispatch.php
------Zend
-- index.php
但是我遇到了到达管理模块的问题。我意识到也许我的问题是路由并且已经实现了一个写入的插件和方法preDispatch()。 Plugin的名称是ModuleDispatch(),位于library / My / Controller / Plugin。
我的application.ini文件是:
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.modules = ""
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.plugins.moduleDispatch=ModuleDispatch
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1
但是在运行时,我总是会收到以下错误:
致命错误:找不到类'ModuleDispatch' /var/www/study/library/Zend/Application/Resource/Frontcontroller.php 在第117行调用堆栈:0.0916 334628 1. {main}() /var/www/study/public/index.php:0 0.5735 1248652 2。 Zend_Application-> bootstrap()/ var / www / study / public / index.php:25 0.5735 1248696 3. Zend_Application_Bootstrap_BootstrapAbstract-> bootstrap() /var/www/study/library/Zend/Application.php:355 0.5735 1248696 4。 Zend_Application_Bootstrap_BootstrapAbstract-> _bootstrap() /var/www/study/library/Zend/Application/Bootstrap/BootstrapAbstract.php:586 0.6280 1282720 5. Zend_Application_Bootstrap_BootstrapAbstract-> _executeResource() /var/www/study/library/Zend/Application/Bootstrap/BootstrapAbstract.php:626 0.6280 1283088 6. Zend_Application_Resource_Frontcontroller-> init()/var/www/study/library/Zend/Application/Bootstrap/BootstrapAbstract.php:683
可能出现什么问题?
答案 0 :(得分:0)
resources.frontController.plugins.moduleDispatch=ModuleDispatch
应该是:
resources.frontController.plugins.moduleDispatch = "My_Controller_Plugin_ModuleDispatch"
并且该类需要命名为My_Controller_Plugin_ModuleDispatch
(区分大小写)。您还需要使用自动加载器注册My_
作为命名空间。
答案 1 :(得分:0)
通过修改application.ini
文件解决了这个问题,如下所示:
[production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
appnamespace = "Application"
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.modules = ""
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
autoloaderNamespaces.plugins = "Plugins_"
resources.frontController.plugins.moduleDispatch= "Plugins_ModuleDispatch"
resources.frontController.baseUrl=/baseUrlSite/
;DB CONFIGURATION
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "username"
resources.db.params.password = "password"
resources.db.params.dbname = "dbname"
resources.db.isDefaultTableAdapter = true
[staging : production]
[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1