【发布时间】:2026-02-13 01:50:01
【问题描述】:
我才真正开始使用 Zend 框架,目前我遇到了 Zend_Loader_PluginLoader 的问题。
我设法使用以下代码让一个特定于模块的插件足够轻松地工作:
class Api_Bootstrap extends Zend_Application_Module_Bootstrap
{
protected function _initPlugins()
{
$loader = new Zend_Loader_PluginLoader(array(
'Api_Plugin' => 'application/modules/api/plugins',
));
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Api_Plugin_ErrorControllerSelectorPlugin());
}
}
编辑:类文件位于application/modules/api/plugins/ErrorControllerSelectorPlugin.php
然后我尝试对此进行调整以使用以下方法为整个应用程序加载插件:
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAppAutoload()
{
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'App',
'basePath' => dirname(__FILE__),
));
return $autoloader;
}
protected function _initPlugins()
{
$loader = new Zend_Loader_PluginLoader(array(
'My_Plugin' => 'application/plugins',
));
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new My_Plugin_ModuleConfigLoaderPlugin());
}
}
但我遇到了错误:
Fatal error: Class 'My_Plugin_ModuleConfigLoaderPlugin' not found in /var/www/localhost/application/Bootstrap.php on line 22
编辑:类文件位于application/plugins/ModuleConfigLoaderPlugin.php
所以 - 由于文件是我希望它们位于发送到 Zend_Loader_PluginLoader() 的前缀/路径对的位置,并且两种情况下的代码相同,有什么区别?
如何让它识别我的应用级插件?
【问题讨论】:
-
My_Plugin_ModuleConfigLoaderPlugin在哪里定位?
标签: php zend-framework