2012-01-10 70 views
2

我正嘗試使用前端和後端模塊設置模塊化Zend Framework項目,但我無法使其工作。當我訪問我的public目錄在Web瀏覽器中,我得到這個錯誤信息:無法啓動模塊化Zend Framework項目

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (error)' in /usr/share/ZendFrameworkCli/library/Zend/Controller/Dispatcher/Standard.php:248 Stack trace: #0 /usr/share/ZendFrameworkCli/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /usr/share/ZendFrameworkCli/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch() #2 /usr/share/ZendFrameworkCli/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run() #3 /Users/Martin/Dropbox/Repositories/realestatecms/public/index.php(25): Zend_Application->run() #4 {main} Next exception 'Zend_Controller_Exception' with message 'Invalid controller specified (error)#0 /usr/share/ZendFrameworkCli/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) in /usr/share/ZendFrameworkCli/library/Zend/Controller/Plugin/Broker.php on line 336

我創建使用Zend Framework命令行工具的兩個模塊,並且這兩個module目錄中稱爲具有Bootstrap.php有兩班分別爲Frontend_BootstrapBackend_Bootstrap

application.ini文件看起來如下:

[production] 
phpSettings.display_startup_errors = 0 
phpSettings.display_errors = 0 
includePaths.library = APPLICATION_PATH "/../library" 
bootstrap.path = APPLICATION_PATH "/Bootstrap.php" 
bootstrap.class = "Bootstrap" 
appnamespace = "Application" 
resources.frontController.controllerDirectory = APPLICATION_PATH "/frontend/controllers" 
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" 
resources.frontController.params.displayExceptions = 0 
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/" 
... 

我做了什麼錯?當我在瀏覽器中訪問http://example.com/public時,如何讓我的Frontend_IndexController()運行?

編輯:如果我每伊萬的回答以線條爲更新我的配置文件,我現在收到此錯誤信息:

Fatal error: Uncaught exception 'Zend_Application_Resource_Exception' with message 'Bootstrap file found for module "default" but bootstrap class "Default_Bootstrap" not found' in /usr/share/ZendFrameworkCli/library/Zend/Application/Resource/Modules.php:83 Stack trace: #0 /usr/share/ZendFrameworkCli/library/Zend/Application/Bootstrap/BootstrapAbstract.php(683): Zend_Application_Resource_Modules->init() #1 /usr/share/ZendFrameworkCli/library/Zend/Application/Bootstrap/BootstrapAbstract.php(626): Zend_Application_Bootstrap_BootstrapAbstract->_executeResource('modules')

2 /usr/share/ZendFrameworkCli/library/Zend/Application/Bootstrap/BootstrapAbstract.php(586):

Zend_Application_Bootstrap_BootstrapAbstract->_bootstrap(NULL) #3 /usr/share/ZendFrameworkCli/library/Zend/Application.php(355): Zend_Application_Bootstrap_BootstrapAbstract->bootstrap(NULL) #4 /Users/Martin/Dropbox/Repositories/realestatecms/public/index.php(25): Zend_Application->bootstrap() #5 {main} thrown in /usr/share/ZendFrameworkCli/library/Zend/Application/Resource/Modules.php on line 83

它從哪兒得到Default_Bootstrap從作爲一個類的名字?

+0

in /modules/default/Bootstrap.php檢查引導類名。模塊引導程序的邏輯位於'Zend_Application_Resource_Modules :: init()' – Xerkus 2012-01-11 01:11:43

回答

1

我有同樣的問題,我發現這個頁面上的解決方案: http://updel.com/zend-framework-modular-application/

您發表評論在/MyApp/application/configs/application.ini以下行:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 

像這樣:

;resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 

它修復了這個問題,不幸的是我沒有足夠的技巧來解釋/理解爲什麼,對不起。 :-)

雖然我希望它有幫助。

0

做你改變這一行:

resources.frontController.controllerDirectory = APPLICATION_PATH "/frontend/controllers" 

我想應該是這樣的:

resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" 

然後,如果你需要其他的默認模塊/控制器不是索引/索引使用這些配置選項:

resources.frontController.defaultControllerName = "index" 
resources.frontController.defaultAction = "index" 
resources.frontController.defaultModule = "frontend" 

而你不應該訪問http://yoursite.com/public。它會引發錯誤。公共目錄應該是你的網站的DocumentRoot,你會獲得這樣的:http://yoursite.com/

+0

Hi Ivan。感謝您花時間回答。我已經更新了我原來的帖子,現在我收到了新的錯誤消息。 – 2012-01-11 00:36:24

+0

我從未更改過默認值。我更喜歡這些任務的路線。 – Xerkus 2012-01-11 01:19:58

+0

確保在你的模塊目錄中你有所有的模塊:前端,後端和默認目錄,以及默認模塊的適當的引導類:「Default_Bootstrap」 – kingdaemon 2012-01-11 09:24:50

0

馬丁,當你調用http://example.com/public的Zend Framework將拋出你看到的,因爲路由器正在尋找錯誤一個控制器名爲public
查看Zend Frame工作網站的正常方法是致電http://example.comhttp://example.com/index.php
對應用程序的所有請求均通過/application/public/index.php進行路由。

它看起來像你原來的配置:

resources.frontController.controllerDirectory = APPLICATION_PATH "/frontend/controllers" 

是爲您的應用程序可能是正確的。

這些都是在的application.ini典型線用於啓用模塊

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" 
resources.frontController.moduleControllerDirectoryName = "controllers" 
resources.frontController.params.prefixDefaultModule = ""//Frontend may be your default 
resources.modules = "" 

可能必須依賴於結構的一些差異。
此外,它通常是有幫助的每一個模塊的目錄,包括它自己的bootstrap.php中擴展* Zend_Application_Module_Bootstrap *

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap { 
    //put your code here 
} 

如果這沒有幫助解決您的問題請提供您的目錄結構和應用程序。 ini(你可以省略數據庫設置等),如果Index.php已經從默認改變了,它將會很有幫助。
也請包含您的Zend Framework版本。