Zend framework zend acl系统中的挣扎

Zend framework zend acl系统中的挣扎,zend-framework,acl,Zend Framework,Acl,我是zend framework的新手,尝试实现zend_acl zend/library/My/Controller/Plugin zend/library/My/Controller/Helper 其中myzend是我项目的目录。我正在尝试从中初始化此自定义插件 引导使用 $frontController = Zend_Controller_Front::getInstance(); $frontController->setControllerDirectory('/path/t

我是zend framework的新手,尝试实现zend_acl

  • zend/library/My/Controller/Plugin
  • zend/library/My/Controller/Helper
其中myzend是我项目的目录。我正在尝试从中初始化此自定义插件 引导使用

$frontController = Zend_Controller_Front::getInstance();
$frontController->setControllerDirectory('/path/to/controllers')
                ->setRouter(new Zend_Controller_Router_Rewrite())
                ->registerPlugin(new My_Controller_Plugin_Acl());
但是我收到了这个错误信息

Fatal error: Uncaught exception 'Zend_Controller_Action_Exception' with message 'Action  index" does not exist and was not trapped in __call()' in C:\xampp\htdocs\zend\library\Zend\Controller\Action.php:485 
Stack trace: 
#0 C:\xampp\htdocs\zend\library\Zend\Controller\Action.php(518): Zend_Controller_Action->__call('indexAction', Array) 
#1 C:\xampp\htdocs\zend\library\Zend\Controller\Dispatcher\Standard.php(308): Zend_Controller_Action->dispatch('indexAction')
#2 C:\xampp\htdocs\zend\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) 
#3 C:\xampp\htdocs\zend\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch() 
#4 C:\xampp\htdocs\zend\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() 
#5 C:\xampp\htdocs\zend\public\index.php(44): Zend_Application->run() 
#6 {main} Next exception 'Zend_Controller_Exception' with message 'Action "index" does not exist and in C:\xampp\htdocs\zend\library\Zend\Controller\Plugin\Broker.php on line 336

请引导我。提前感谢。

将插件放入
库/Controller/Plugin/Acl.php
中,然后将其添加到应用程序中(建议使用引导)


您的代码更改了默认控制器目录,因此Zend无法在preDispatch()方法中的重定向中找到正确的操作,请尝试以下操作:

$request->setActionName('error');
而不是:

$request->setActionName('index'); 
如果要出错,请尝试以下操作:

throw new Zend_Acl_Exception("Not allowed");
而不是

$request->setControllerName('Error'); 
$request->setActionName('index'); 

错误看起来与插件无关。如果删除这两行,您确定一切正常吗?是的,当我注释$frontController变量时,错误消失了。在这两行中发现错误$frontController=Zend_Controller_Front::getInstance()$frontController->setControllerDirectory('/path/to/controllers')->setRouter(新Zend_控制器_路由器_重写())->registerPlugin(新My_控制器_插件_Acl());是你的插件扩展了Zend_Controller_插件_Abstract吗?是的。该插件扩展了Zend_Controller_plugin_Abstract。您在插件中的postdispatch()方法中有重定向吗?@Manikandan:我在回答中添加了一个解决方案
errorAction
方法没有获取getParam对象
$errors=$this->\u getParam('error\u handler')是否有人可以解释否决票的原因?:)您是否删除了
->setControllerDirectory('/path/to/controllers')
和`->setRouter(新的Zend\u Controller\u Router\u Rewrite())`?
$request->setControllerName('Error'); 
$request->setActionName('index');