【问题标题】:Plugin not found error in Zend modular applicationZend 模块化应用程序中未找到插件错误
【发布时间】:2013-05-01 06:43:17
【问题描述】:

我想做一个 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

但是我在访问管理模块时遇到了问题。我意识到也许我的问题是路由,并且已经实现了一个编写的 Plugin 和方法 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

可能出了什么问题?

【问题讨论】:

  • 我们鼓励您在最终解决问题时发布解决方案,但您应该将其作为答案发布,而不是将其作为对问题的编辑.我已经在这里为你做了这些,但只是为了将来记住一些事情。

标签: zend-framework plugins


【解决方案1】:
resources.frontController.plugins.moduleDispatch=ModuleDispatch

应该是:

resources.frontController.plugins.moduleDispatch = "My_Controller_Plugin_ModuleDispatch"

并且该类需要命名为My_Controller_Plugin_ModuleDispatch(区分大小写)。您还需要将My_ 注册为自动加载器的命名空间。

【讨论】:

  • 我在我的 fil application.ini 中添加了以下行: autoloaderNamespaces[] = "My_" resources.frontController.plugins.moduleDispatch = "My_Controller_Plugin_ModuleDispatch" 我将类和文件重命名为:My_Controller_Plugin_ModuleDispatch但我收到以下错误警告:include_once(My/Controller/Plugin/ModuleDispatch.php): failed to open stream: No such file or directory in
  • 该错误的其余部分应显示它为类检查的包含路径。它是否显示您的库文件夹?
  • 在什么意义上表明我的库文件夹是可见的?允许吗?
  • 尝试将autoloaderNamespaces[] = "My_" 添加到application.ini。
  • autoloaderNamespaces[] = "My_" 已经存在于文件 application.ini 中
【解决方案2】:

问题通过修改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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-05-22
    • 2021-05-30
    • 2019-04-26
    • 2017-03-09
    • 2022-06-10
    • 2019-04-26
    • 1970-01-01
    相关资源
    最近更新 更多