Zend框架中的错误报告 [英] Error reporting in zend framework

查看:28
本文介绍了Zend框架中的错误报告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Zend 框架中报告错误时遇到问题,错误消息未显示在浏览器上,我收到这样的错误:

<块引用>

发生错误

应用错误

但是我已经在我的 application.ini 文件中使用了这些配置:

phpSettings.display_startup_errors = 1phpSettings.display_errors = 1phpSettings.track_errors = 1phpSettings.error_reporting = E_ALL

提前致谢:D

解决方案

您提到的设置是 php 错误管理,而您要查找的实际上是 Zend 错误和异常报告.正如kjy112提到的,看起来Zend默认为生产环境,不显示任何错误报告.

Zend 快速入门可能是帮助您加快速度的最快方法:http://framework.zend.com/manual/en/zend.application.quick-start.html

基本上你可以在你的 index.php 文件中设置一个定义(不是最干净的),或者我建议在你的 apache 配置中设置它,然后从你的 index.php 文件中读取它.我在 Bootstrap 中使用了这样的东西:

if (!defined('APPLICATION_ENVIRONMENT')){如果(getenv('APPLICATION_ENVIRONMENT')){定义('APPLICATION_ENVIRONMENT', getenv('APPLICATION_ENVIRONMENT'));} 别的 {定义('APPLICATION_ENVIRONMENT','生产');}}

默认的 Zend error.phtml 视图具有类似于以下代码的内容,它阻止了生产环境中的显示:

env): ?><div id="错误"><p><ul class="errorList"><li><h3><?php echo $this->message ?></h3><li><h4>异常信息:</h4><p><?php echo $this->exception->getMessage() ?></p><li><h4>堆栈跟踪:</h4><p><?php echo $this->exception->getTraceAsString() ?></p><li><h4>请求参数:</h4><p><?php var_dump($this->request->getParams()) ?></p></p>

<?php endif ?>

am having trouble with reporting errors in zend framework, errors messages are not displayed on the browser and i recive error's like this:

An error occurred

Application error

However i already use those configuration in my application.ini file:

phpSettings.display_startup_errors = 1

phpSettings.display_errors = 1

phpSettings.track_errors = 1

phpSettings.error_reporting = E_ALL

Thanks in advance :D

解决方案

The settings you are mentioning are php error management, whereas what you are looking for is really the Zend error and exception reporting. As kjy112 mentioned, it looks like Zend is defaulting to the production environment, which does not display any of the error reporting.

The Zend quickstart may be the fastest way to help get you up to speed on this: http://framework.zend.com/manual/en/zend.application.quick-start.html

Basically you can either set a define inside of your index.php file (not the cleanest), or I recommend setting it in your apache configuration and then reading it from your index.php file. I use something like this in my Bootstrap:

if (!defined('APPLICATION_ENVIRONMENT'))
{
    if (getenv('APPLICATION_ENVIRONMENT')) {
        define('APPLICATION_ENVIRONMENT', getenv('APPLICATION_ENVIRONMENT'));
    } else {
        define('APPLICATION_ENVIRONMENT', 'production');
    }
}

The default Zend error.phtml view has something akin to the following code, which blocks the display in the production environment:

<?php if ('production' !== $this->env): ?>
<div id="error">
    <p>
        <ul class="errorList">
            <li>
                <h3><?php echo $this->message ?></h3> 
            </li>
            <li>
                <h4>Exception information:</h4>
                <p><?php echo $this->exception->getMessage() ?></p>
            </li>
            <li>
                <h4>Stack trace:</h4>
                <p><?php echo $this->exception->getTraceAsString() ?></p>
            </li>
            <li>
                <h4>Request Parameters:</h4>
                <p><?php var_dump($this->request->getParams()) ?></p>
            </li>
        </ul>
    </p>
</div>
<?php endif ?>

这篇关于Zend框架中的错误报告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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