我在CakePHP 3中有500个服务器错误的自定义错误页面。
我的src\Template\Layout\error.ctp
模板文件已经过调整,其中包含我的默认错误模板。然后我还在src\Template\Error\error500.ctp
更新了我的视图文件。我甚至按照docs中的说明添加了这一行$this->layout = 'error';
。
这就是我的错误视图:
<?php
use Cake\Core\Configure;
use Cake\Error\Debugger;
$this->layout = 'error';
$this->Html->addCrumb('Error');
?>
<section class="content">
<div class="error-page">
<h2 class="headline text-red">500</h2>
<div class="error-content">
<h3><i class="fa fa-warning text-red"></i> Oops! Something went wrong.</h3>
<p>
We will work on fixing that right away.
Meanwhile, you may <a href="../../index.html">return to dashboard</a> or try using the search form.
</p>
</div>
</div>
</section>
但是,它仍然显示默认的CakePHP错误页面。
我错过了什么?
答案 0 :(得分:2)
只需关闭app.php
中的调试
'debug' => false
正如在食谱中写的那样
每个框架层异常都有自己的视图文件位于核心模板中,但您实际上不需要打扰它们,因为它们仅在开发期间使用。 关闭调试后,所有框架层异常都将转换为InternalErrorException
有关ExceptionRenderer的详细信息,请访问here