【转】zend framework 2 中让空白页面显示错误信息

3350阅读 0评论2015-03-27 fireaxe
分类:LINUX




开发软件项目时显示错误,警告等信息非常利于我们调试程序。

zend framework 2 很多设置都是在配置文件中,如果设置不当,经常会碰到空白页面的情况。

这种情况下基本上是我们的配置或者程序中出现错误,但zf2的配置文件,以及程序代码分散得很厉害,

这很不利于我们判断错误到底出现在哪里。所以让错误提示显示出来就很有必要。

zf2显示错误提示也很简单。

首先在我们的服务器配置文件中添加development环境变量: SetEnv APPLICATION_ENV “development”

    ServerName zf2-tutorial.local
    DocumentRoot "/Users/sai/Sites/valuation/public"
    SetEnv APPLICATION_ENV "development"
    
        Options Indexes MultiViews FollowSymLinks
        AllowOverride All
        Order deny,allow
        Allow from all
    


其次在项目根目录的public/index.php中设置error_reporting为E_ALL,display_errors为true.

public/index.php

// Display all errors when APPLICATION_ENV is development.
if (defined('APPLICATION_ENV'))
    if ($_SERVER['APPLICATION_ENV'] == 'development') {
        error_reporting(E_ALL);
        ini_set("display_errors", 1);
    }
 
chdir(dirname(__DIR__));
......


上一篇:ubuntu 14.04 设置caps为ctrl
下一篇: 【转】Zend Framework2 入门教程