【发布时间】:2019-06-28 10:07:03
【问题描述】:
在执行bin/console cache:clear 时,调试器不会在第一行代码处停止。
以下输出显示在 xdebug 日志中。
[18806] Log opened at 2019-02-04 15:58:42
[18806] I: Checking remote connect back address.
[18806] I: Checking header 'HTTP_X_FORWARDED_FOR'.
[18806] I: Checking header 'REMOTE_ADDR'.
[18806] W: Remote address not found, connecting to configured address/port: 10.0.2.2:9000. :-|
[18806] I: Connected to client. :-)
[18806] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///home/vagrant/projects/valkplanner2/bin/console" language="PHP" xdebug:language_version="7.3.0RC3" protocol_version="1.0" appid="18806" idekey="PHPSTORM"><engine version="2.7.0beta1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
[18806]
我正在使用 PhpStorm 2018.3.3。 以下是我在 PhpStorm 中的调试配置:
这是/etc/php/7.3/cli/php.ini中的Xdebug配置。
[xdebug]
xdebug.remote_enable=1
xdebug.remote_log="/home/vagrant/xdebug.log"
xdebug.remote_handler=dbgp
xdebug.collect_params=1
xdebug.remote_connect_back=0
;use `route -n` to find dev machine IP address from homestead environment (seems to default to 10.0.2.2)
xdebug.remote_host="10.0.2.2"
xdebug.default_enable=1
xdebug.remote_autostart=1
xdebug.show_local_vars=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir='/home/vagrant/profile'
xdebug.idekey=PHPSTORM
当我使用 URL 中的 ?XDEBUG_SESSION_START=PHPSTORM 或 Chrome 调试器插件向浏览器或 Postman 发出请求时,调试器工作正常。
日志显示与 xdebug 的通信正常,但 PhpStorm 没有反应。
有谁知道问题出在哪里?
【问题讨论】:
-
将 Xdebug 端口更改为 9001(或默认 9000 中的其他数字)。您可能正在连接到其他服务而不是 PhpStorm(例如 php-fpm 是在 Mac/Linux 上侦听 TCP 9000 端口的服务,是“调试不起作用”的典型原因);使用
sudo lsof -nP -iTCP -sTCP:LISTEN检查谁在运行 PhpStorm 的计算机/操作系统上监听该端口(在 Mac 上 PhpStorm 无法检测到该端口已被使用)。 -
“日志表明与 xdebug 的通信正常,但 PhpStorm 没有反应。” 您的日志不完整/被截断......所以它可以是任何东西。
-
非常感谢,php-fpm 像 phpstorm 一样监听 9000 端口。我将端口更改为 9001,现在它可以工作了!
标签: vagrant phpstorm xdebug symfony4 homestead