Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1350410
  • 博文数量: 118
  • 博客积分: 3888
  • 博客等级: 中校
  • 技术积分: 2940
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-10 18:15
个人简介

一看二做三总结

文章分类

全部博文(118)

分类: LINUX

2015-03-27 16:38:37




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

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__));
......


阅读(3337) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~