2010-05-02 37 views
8

嗨,大家好我正在使用Zend框架,只是討厭我似乎遇到數百個異常錯誤,如果我嘗試引用一個對象的不存在的屬性我的事實我應用程序就會死亡並崩潰。但是,我不知道在哪裏看到這些錯誤或如何能夠在屏幕上顯示它們。我將顯示錯誤設置爲true,並向E_ALL報告錯誤,但是當拋出錯誤時,我所看到的只是一個空白頁面,直到顯示錯誤或引發異常之前的一段時間。如何顯示由Zend框架引發的異常錯誤

請幫助我調試小時拖動

回答

4

APPLICATION_ENV環境變量的值是什麼。

在ZF應用程序的標準的公共/ index.php文件執行以下操作:

// Define application environment 
defined('APPLICATION_ENV') 
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); 

這意味着,如果沒有APPLICATION_ENV設置,環境設置爲「生產」。如果你看看你的application.ini文件,你會發現如果環境是生產環境的話,框架可以抑制錯誤。

當然,你正在開發,所以你想使用'開發'環境。

如果你在Apache/mod_php的運行,你可以把這個在你的httpd.conf,或.htaccess文件:

SetEnv APPLICATION_ENV development 

或者你總是可以得到醜陋,謬以千里,在你的公共/ index.php:

// Define application environment 

/*defined('APPLICATION_ENV') 
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));*/ 

// Ugly hack because I'm too lazy to properly set up my environment. 
define('APPLICATION_ENV','development'); 
+0

對於簡單的答案和解釋它的作用+1。它的工作原理:) – Benj 2012-12-14 10:22:28

+0

感謝提到它可以在httpd.conf中設置! – Christian 2013-07-15 14:07:11

1

引用一個不存在的屬性是一個錯誤在PHP中,也不例外。如果在你的php.ini中啓用display_errors,錯誤通常在html的輸出中。但要注意:他們可以像一個無形的HTML標籤中,以及發生:

<div style="display:none"><? echo $object->nonexistant?> ... 

...所以你需要檢查你的頁面的HTML輸出(CTRL-U在Firefox),並滾動至底部

+0

一個異常被拋出,當我嘗試訪問它似乎是一個對象的不存在的屬性。考慮到所討論的對象可能有或沒有我想檢查的財產,是否有辦法解決這個問題。 – Ali 2010-05-03 07:44:25

2

如果使用Zend Tool創建應用程序框架,通常會有一個錯誤控制器來捕獲運行時錯誤並顯示它們。你要遵循timdev的建議SetEnv APPLICATION_ENV development,然後在您的應用程序/ CONFIGS /的application.ini:

[development : production] 

; This section defines config parameters loaded when the APPLICATION_ENV directive 
; is set to 'development' - undefined parameters are inherited from the production 
; section. 

; show errors and exceptions during development 
phpSettings.display_startup_errors = 1 
phpSettings.display_errors = 1 
resources.frontController.params.displayExceptions = 1