如何显示Zend框架抛出的异常错误 [英] How do I display exception errors thrown by Zend framework

查看:110
本文介绍了如何显示Zend框架抛出的异常错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Zend框架,只是讨厌一个事实,我似乎遇到了数百个异常错误,如我试图引用我的应用程序刚刚死机和崩溃的对象的一个​​不存在的属性。但是我不知道在哪里看到这些错误或者如何在屏幕上显示它们。我将显示错误设置为E_ALL的错误报告,但是当抛出错误时,我看到的只是一个空白页面呈现,直到出现错误显然发生或发生异常之前。



帮助我的调试时间是拖动

解决方案

APPLICATION_ENV环境变量的价值是什么? / p>

ZF应用程序中的标准public / index.php执行以下操作:

  //定义应用程序环境
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开发

或者你可以总是在你的公开/ index.php中丑陋并被黑客攻击:

  //定义应用程序环境

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

//丑陋的黑客,因为我太懒了,我的环境
define('APPLICATION_ENV','development');


Hi guys I'm working with Zend framework and just hate the fact that I seem to encounter hundreds of exception errors like if I try to reference a non existant property of an object my application just dies and crashes. However I have no idea where to see these errors or how to be able to display them on screen. I've set display errors to true and error reporting to E_ALL but when an error is thrown all I see is a blank page rendered only until a bit before where the error apparently occurred or the exception was thrown.

Help please my debugging hours are dragging

解决方案

What's the value of the APPLICATION_ENV environment variable.

The standard public/index.php in a ZF application does the following:

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

This means that if no APPLICATION_ENV is set, the environment is set as "production". If you look at your application.ini file, you'll see that the framework suppresses errors if the environment is production.

Of course, you're developing, so you want to use the 'development' environment.

If you're running under Apache/mod_php, you can set this in your httpd.conf, or an .htaccess file:

SetEnv APPLICATION_ENV development

Or you could always get ugly and hack away at your public/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');

这篇关于如何显示Zend框架抛出的异常错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆