Zend插件使用什么目录?

Art*_*kel 6 php zend-framework

假设我的ini文件中包含以下内容:

resources.frontController.plugins.auth = AuthPlugin
Run Code Online (Sandbox Code Playgroud)

应该在哪里放置AuthPlugin类?假设我想在控制器/插件下使用它.

更新:

根据以下建议,我仍然遇到麻烦.让我准确地说我现在拥有的东西:

1)application.ini的主要部分

includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.view[] =
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.plugins.authplugin.class = "AuthPlugin"
Run Code Online (Sandbox Code Playgroud)

2)我的Bootstrap.php什么都没有(我有很多东西,但仍然没有任何错误):

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
}
Run Code Online (Sandbox Code Playgroud)

3)我在application/plugins目录中有一个AuthPlugin.php类

class AuthPlugin extends Zend_Controller_Plugin_Abstract
{
    public function preDispatch(Zend_Controller_Request_Abstract $request)
        { 
           // code here
        }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Fatal error: Class 'AuthPlugin' not found in C:\[my dir structure here]\Application\Resource\Frontcontroller.php on line 111
Run Code Online (Sandbox Code Playgroud)

我想我在这里遗漏了一些明显的东西.提前致谢.Zend Framework 1.10

jah*_*jah 3

这是我在应用程序配置中注册名为 Foo_Plugin_SuperDuperPlugin 的插件的方法:

resources.frontController.plugins.superduperplugin.class = "Foo_Plugin_SuperDuperPlugin"
Run Code Online (Sandbox Code Playgroud)

该插件位于
APPLICATION_PATH/plugins/Foo_Plugin_SuperDuperPlugin.php此处并从那里自动加载,因为资源模块自动加载器会自动在该(推荐)位置查找插件类型资源。如果我想从中加载插件,那么
APPLICATION_PATH/controllers/plugins/Foo_Plugin_SuperDuperPlugin.php我将使用自动加载器注册一个新的资源加载器,并定义一种名为“插件”的资源类型以及这些插件资源的路径。所以在我的 bootstrap.php 中

protected function _initAutoloader()
{
    $autoloader = new Zend_Loader_Autoloader_Resource(
        array(
            'basePath'      => APPLICATION_PATH,
            'namespace'     => 'Foo',
            'resourceTypes' => array(
                'plugin' => array(
                    'path'      => 'controllers/plugins',
                    'namespace' => 'Plugin',
                )
            )
        )
    );
}
Run Code Online (Sandbox Code Playgroud)

然后我需要确保在注册 SuperDuperPlugin 之前引导此方法(在本示例中,在读取应用程序配置时发生resources.frontcontroller.plugins.superduperplugin.class = ...)。这可以通过在 frontController 资源初始化之前_initAutoloader将该方法放置在 bootstrap.php 的顶部或从任何其他 _init 方法调用来实现。$this->bootstrap('autoLoader');

更新:尝试将其添加到您的引导程序中:

protected function _initAutoloader()
{
    $autoloader = new Zend_Loader_Autoloader_Resource(
        array(
            'basePath'      => APPLICATION_PATH,
            'resourceTypes' => array(
                'plugin' => array(
                    'path'      => 'controllers/plugins',
                    'namespace' => '',
                )
            )
        )
    );
}
Run Code Online (Sandbox Code Playgroud)

甚至可能省略名称空间。或者:添加appnamespace = "Foo"到您的配置中并将该类重命名为Foo_Plugin_AuthPlugin.