我的插件目录位于
application
/plugins
Dbcount.php
ModuleLayout.php
我无法使用frontController注册该插件。这是我的application.ini代码。
#Plugin path and namespace
pluginPaths.Plugins = APPLICATION_PATH "/plugins"
autoloaderNamespaces[] = "Plugin_"
#register plugin
resources.frontController.plugins[] = "Plugin_DbCount"
它给了我以下错误。
Warning: include_once(Plugin/DbCount.php) [function.include-once]: failed to open stream: No such file or directory in /Users/azhararmar/htdocs/joofris/v1/library/Zend/Loader.php on line 146
Warning: include_once() [function.include]: Failed opening 'Plugin/DbCount.php' for inclusion (include_path='/Users/azhararmar/htdocs/joofris/v1/application/../library:/Users/azhararmar/htdocs/joofris/v1/library:.:/Applications/MAMP/bin/php5.2/lib/php') in /Users/azhararmar/htdocs/joofris/v1/library/Zend/Loader.php on line 146
Fatal error: Class 'Plugin_DbCount' not found in /Users/azhararmar/htdocs/joofris/v1/library/Zend/Application/Resource/Frontcontroller.php on line 117
出了什么问题?
答案 0 :(得分:3)
如果您使用默认的appnamespace Application
,则application/plugins/DbCount.php
中存储的插件应命名为Application_Plugin_DbCount
。注册时使用完整的类名:
resources.frontController.plugins[] = "Application_Plugin_DbCount"
答案 1 :(得分:1)
要使用名称空间,您的Plugin
类需要位于库下,或者您需要将它们映射到其他位置。看起来你的前置控制器插件设置正确但自动加载定义不正确。
最简单的方法是命名插件YourAppNamespace_Plugin_YourPluginName
。
答案 2 :(得分:1)
它们是ZF中的两种类型的插件。你正在混合每个部分。
使代码正常工作
1) put application dir in include_path
2) change directory name plugins to 'Plugin'