英文:
CakePHP: Debug messages not shown
问题
我在 config/app_local.php
文件中有这段代码:
return [
/*
* Debug Level:
*
* Production Mode:
* false: 不显示错误消息、错误或警告。
*
* Development Mode:
* true: 显示错误和警告。
*/
'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
'DebugKit' => ['forceEnable' => TRUE],
...
之前在日志文件中我看到了这个警告:
警告:由于您的主机 `my.example.com` 不在已知安全域名列表中(localhost, invalid, test, example, local),DebugKit 自行禁用。
如果您想强制启用 DebugKit,请使用 `DebugKit.forceEnable` 配置选项。
在我设置了上述代码后,警告已经消失,但当发生错误时,我仍然看不到 CakePHP 调试窗口。我只看到这个:
致命错误:App\Controller\ErrorController::beforeRender(Cake\Event\EventInterface $event) 的声明必须与 App\Controller\AppController::beforeRender(Cake\Event\EventInterface $event) 兼容:void,位于 /var/www/vhosts/example.ocm/my.example.com/src/Controller/ErrorController.php 的第 54 行
我还缺少什么,做错了什么吗?调试消息仅在日志文件中,但我也希望在浏览器中看到它。
英文:
I have in config/app_local.php
this code:
return [
/*
* Debug Level:
*
* Production Mode:
* false: No error messages, errors, or warnings shown.
*
* Development Mode:
* true: Errors and warnings shown.
*/
'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
'DebugKit' => [ 'forceEnable' => TRUE],
...
Before I had this warning in the log file:
warning: DebugKit is disabling itself as your host `my.example.com` is not in the known safe list of
top-level-domains (localhost, invalid, test, example, local).
If you would like to force DebugKit on use the `DebugKit.forceEnable` Configure option.
After I set the above code the warning has gone but I still don't see the CakePHP debug window when an error occurs. I see only this:
Fatal error: Declaration of App\Controller\ErrorController::beforeRender(Cake\Event\EventInterface $event)
must be compatible with App\Controller\AppController::beforeRender(Cake\Event\EventInterface $event):
void in /var/www/vhosts/example.ocm/my.example.com/src/Controller/ErrorController.php on line 54
What am I still missing, doing wrong? The debug message is only in the log file, but I would like to see it also in the browser.
答案1
得分: 1
错误消息指出,这两个函数的原型不匹配。AppController 上的 : void
表示该函数不会返回任何内容。ErrorController 缺少这一点。它们需要匹配。
英文:
As the error message indicates, the prototypes of the two functions do not match. The : void
on the AppController indicates that the function won't return anything. The ErrorController is missing this. They need to match.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论