Vagrant 在Homestead中执行Symfony控制台命令时Xdebug不工作

Vagrant 在Homestead中执行Symfony控制台命令时Xdebug不工作,vagrant,phpstorm,xdebug,symfony4,homestead,Vagrant,Phpstorm,Xdebug,Symfony4,Homestead,执行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]

执行
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]
当我使用URL中的
?XDEBUG\u SESSION\u START=PHPSTORM
或Chrome debugger插件通过浏览器或邮递员请求时,调试器工作正常

日志表明与xdebug的通信是有效的,但PhpStorm没有反应


有人知道问题出在哪里吗?

听起来像是另一个服务在Xdebug端口而不是PhpStorm上监听

在Mac上,PhpStorm无法检测Xdebug端口是否已被其他服务使用()

您可以使用
sudolsof-nP-iTCP-sTCP:LISTEN
sort命令查看该服务可能是什么。最有可能是php fpm(因为它默认使用TCP 9000端口)。在Mac和Linux上,php fpm很可能安装在您的开发机器上(通常与php一起安装)


解决方案:将Xdebug端口从默认的
9000
更改为另一个端口,通常是下一个--
9001
。在php.ini和PhpStorm中执行此操作(确保此时未侦听调试连接;如果侦听,请停止并重新启动)。如果您正在使用某些Web服务器(例如Apache),则可能还需要重新启动该服务器(以便PHP读取新配置)。

将Xdebug端口更改为9001(或默认9000的其他数字)。您可能正在连接到另一个服务,而不是PhpStorm(例如,php fpm是在Mac/Linux上侦听TCP 9000端口的服务,是导致“调试不工作”的典型原因);使用
sudo lsof-nP-iTCP-sTCP:LISTEN
检查谁在运行PhpStorm的计算机/操作系统上监听该端口(在Mac上PhpStorm无法检测到该端口已被使用)。“日志表明与xdebug的通信正常,但PhpStorm没有反应。”您的日志不完整/被截断。。。所以它可以是任何东西。非常感谢,php fpm正在侦听端口9000以及phpstorm。我将端口更改为9001,现在它可以工作了!
[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