在 CLI 中禁用 Xdebug 3 "Could not connect" 消息
Disable Xdebug 3 "Could not connect" message in CLI
在 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 版本中有其他方法(恕我直言,这应该只是一个弱警告)。
编辑:如 LazyOne 所述,也可以在 php.ini
中为 error_log
设置一个值,例如 /var/log/php_error.log
。通过该更改,日志条目将写入此文件,而不是发送到 stderr。
这是您需要的:
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.discover_client_host=1
在我的例子中,问题是 Xdebug 尝试在每个请求上 运行,因为我没有对每个页面进行调试,因此报告了 Xdebug: [Step Debug] Could not connect to debugging client
之类的刷新错误,这是可以理解的。
xdebug.log_level = 0
最明显的解决方案当然有效,但对于我来说,这种方法过于宽泛和盲目。所以我检查了 documentation,我认为消除该错误的最佳方法是告诉 Xdebug 什么时候它真的应该 运行 什么时候不应该,所以在我的情况下正确的选择是:
xdebug.start_with_request = trigger
如文档所述:
The functionality only gets activated when a specific trigger is
present when the request starts.
The name of the trigger is XDEBUG_TRIGGER, and Xdebug checks for its
presence in either $_ENV (environment variable), $_GET or $_POST
variable, or $_COOKIE (HTTP cookie name).
我建议至少检查 their docs 的那一部分,因为有更多信息,如果需要,您甚至可以做更多微调。
从 3.1 版开始,如果您设置日志文件的路径,xdebug 不会将其日志重定向到 php 日志。就我而言,我使用以下设置,这些消息不再使控制台中的眼睛眼花缭乱
xdebug.log=/var/www/var/log/xdebug.log
xdebug.log_level=3
在 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 版本中有其他方法(恕我直言,这应该只是一个弱警告)。
编辑:如 LazyOne 所述,也可以在 php.ini
中为 error_log
设置一个值,例如 /var/log/php_error.log
。通过该更改,日志条目将写入此文件,而不是发送到 stderr。
这是您需要的:
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.discover_client_host=1
在我的例子中,问题是 Xdebug 尝试在每个请求上 运行,因为我没有对每个页面进行调试,因此报告了 Xdebug: [Step Debug] Could not connect to debugging client
之类的刷新错误,这是可以理解的。
xdebug.log_level = 0
最明显的解决方案当然有效,但对于我来说,这种方法过于宽泛和盲目。所以我检查了 documentation,我认为消除该错误的最佳方法是告诉 Xdebug 什么时候它真的应该 运行 什么时候不应该,所以在我的情况下正确的选择是:
xdebug.start_with_request = trigger
如文档所述:
The functionality only gets activated when a specific trigger is present when the request starts.
The name of the trigger is XDEBUG_TRIGGER, and Xdebug checks for its presence in either $_ENV (environment variable), $_GET or $_POST variable, or $_COOKIE (HTTP cookie name).
我建议至少检查 their docs 的那一部分,因为有更多信息,如果需要,您甚至可以做更多微调。
从 3.1 版开始,如果您设置日志文件的路径,xdebug 不会将其日志重定向到 php 日志。就我而言,我使用以下设置,这些消息不再使控制台中的眼睛眼花缭乱
xdebug.log=/var/www/var/log/xdebug.log
xdebug.log_level=3