0

I've found the guidance here how to start with Zend Acl, going throuh the steps of the best answer but I've become stuck on this operation:

Final steps are loading your configAcl.php and register the AuthPlugin in bootstrap file (probably index.php).

When I start my application, it tells me

Fatal error: Class 'AuthPlugin' not found in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\myproject\public\index.php on line 28

but I have put this plugin in applications/plugins folder. I'm new to Zend Framework and using v.1.12 (because I didn't find out how to create project in new version: the command-line app in bin folder was missing).

Maybe I have to edit my Bootstrap.php file, but I don't know how. Every instruction I found looks like for another version of framework, because the code in their public/index.php is very different from mine.

4

3 回答 3

0

Require_once 不适用于我的项目.. 任何其他包含插件的方式

于 2014-02-21T09:18:59.650 回答
0

所以在坐了一个小时后,我终于找到了怎么做。老实说,如果我的 Firefox 没有向我显示错误,我会更快地找到我的问题的答案,即我的应用程序页面以递归方式重定向。Firefox 重启后问题消失。所以这就是答案:在您的引导程序中使用以下代码。

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initAutoload() {
    require_once '../application/plugins/AuthPlugin.php';
    require_once '../application/configs/configAcl.php';
}

protected function _initControllerPlugins()
{

$frontController = Zend_Controller_Front::getInstance();
$frontController->registerPlugin(new AuthPlugin());

}
}

希望这对我这样的 Zend Framework 新手有所帮助。

于 2013-02-07T23:16:45.900 回答
0

我知道这是一个非常老的问题,但我会留下我找到的答案,以防有人偶然发现这个线程。

虽然您发布的答案有效,但我通过 application.ini 找到了另一个答案。ZF 遵循命名标准: Plugin_ViewSetup 解析为 Plugin/ViewSetup.php 。对于插件,ZF 会自动查找“库路径”,这意味着它会在您的库目录(Zend 库所在的位置)中查找。所以插件应该如下: library/Plugin/ViewSetup.php ...这是一种情况。然后,您只需在 application.ini 中添加以下内容:

autoloaderNamespaces[] = "Plugin_"
resources.frontController.plugins.ViewSetup = "Plugin_ViewSetup"

翻译成你的情况是:

autoloaderNamespaces[] = "Plugins_"
resources.frontController.plugins.AuthPlugin = "Plugins_AuthPlugin"

你的图书馆结构应该是:

library/Plugins/AuthPlugin.php

希望这对偶然发现这里的人有所帮助!

于 2013-05-25T09:48:26.333 回答