我在报告 zend 框架中的错误时遇到问题,错误消息未显示在浏览器上,我收到的错误如下:
An error occurred
Application error
但是我已经在我的 application.ini 文件中使用了这些配置:
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
phpSettings.track_errors = 1
phpSettings.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'))
{
if (getenv('APPLICATION_ENVIRONMENT')) {
define('APPLICATION_ENVIRONMENT', getenv('APPLICATION_ENVIRONMENT'));
} else {
define('APPLICATION_ENVIRONMENT', 'production');
}
}
默认的 Zend error.phtml View 具有类似于以下代码的内容,它会阻止在生产环境中显示:
<?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 ?>
关于php - zend框架报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5393040/