Rob*_*Rob 3 php zend-framework zend-framework2
当产生解析错误时,例如在控制器内部,ZF2异常处理程序捕获它并且我只看到
An error occurred during execution; please try again later.
No exception available
Run Code Online (Sandbox Code Playgroud)
如果我在内部产生解析错误,public/index.php我可以在浏览器中看到简单的 PHP 错误,因此 PHP 设置是正确的。
如何强制 ZF2 在开发模式下显示此类错误?
事实证明,我使用的是旧版本view/error/index.phtml(骨架应用程序的一部分),它没有为 Error 类型的错误做好准备(自 PHP 7 起),并且只处理 Exception 类型的错误。
必须改变这条线
<?php if(isset($this->exception) && $this->exception instanceof Exception): ?>
Run Code Online (Sandbox Code Playgroud)
对此
<?php if (isset($this->exception) && ($this->exception instanceof \Exception || $this->exception instanceof \Error)) : ?>
Run Code Online (Sandbox Code Playgroud)