2013-02-07 34 views
0

我已經找到了指導here如何開始與Zend ACL時,會throuh最佳答案的步驟,但我已經成爲停留在這個操作:如何使對ZF Zend_Acl裏工作1.12

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

當我開始我的應用程序,它告訴我

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

但我已經把這個插件在應用程序/插件文件夾。我是Zend Framework的新手,並使用v.1.12(因爲我沒有發現如何在新版本中創建項目:bin文件夾中的命令行應用程序缺失)。

也許我不得不修改我的bootstrap.php文件,但我不知道怎麼辦。我發現的每條指令看起來都像另一個版本的框架,因爲public/index.php中的代碼與我的代碼非常不同。

回答

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這樣的新手。

0

我知道it's一個非常古老的問題,但I'm離開我找到了答案,以防有人絆倒在這個線程。

雖然您發佈的答案有效,但我通過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 

希望這有助於任何人在這裏磕磕絆絆!

0

Require_once不適用於我的項目..任何其他方式包括插件