在CLI中禁用Xdebug3“无法连接”消息
在 CLI 中使用 Xdebug 3 时,它会在没有设置断点时不断报告消息:
"Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-("
有没有办法禁用在 CLI 中显示的消息表单?
回答
不幸的是,禁用此错误的唯一方法是禁用 xdebug.ini 中的所有错误和警告:
xdebug.log_level = 0
希望在未来的 xdebug 版本中还有其他方式(恕我直言,这应该只是一个弱警告)。
- Xdebug should write such text into PHP error log ... and it does it here on Windows 10 (PHP 7.4 and 8.0 -- NTS build, x64). I do not see such warning here when doing my tests in terminal -- it arrives into the log ifle as it should (using default `xdebug.log_level` value, which is `7`). Perhaps it's some output redirection (error output stream or alike).
- With `echo "<?php" | php` on Ubuntu with default xdebug.log_level and without listing to PHP debug connection, I get this message: "Xdebug: [Step Debug] Could not connect to debugging client. Tried: localhost:9003 (through xdebug.client_host/xdebug.client_port) :-("
- @haby What's the value of the `error_log` PHP settings. (e.g. from phpinfo(); output or just ini_get('error_log');). I believe it will be empty (or perhaps some incorrect location). If you set it to some proper location (e.g. something like `/var/log/php_error.log` or maybe even `/dev/null` - -depends n your OS and distro) then you should not see such error in the first place. Can you do that and check the same that you did in your first comment here?
- You're right, it's empty. Setting it to the suggested filename and setting correct permissios, the error message disappear. I hadn't such behaviour with xdebug2, but thanks anyway.