CakePHP: 调试消息未显示

huangapple go评论44阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月1日 02:37:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76376411.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定