XDEBUG 无法正常工作,但已安装且日志显示 "Connect to client :-)"
XDEBUG not working properly, but is installed and log says "Connect to client :-)"
xDebug 已安装,日志已启用,验证正常,日志告诉我 xdebug 可以连接到客户端;但是 - 与 IDE
没有联系
- 在 Docker
中使用 PHP7 安装了 xDebug
- 在环境中添加了相应的ini文件
- 设置断点
- 在 CLI 和 FPM 中验证 xDebug
20-xdebug.ini:
xdebug.idekey=PHPSTORM
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_host=172.55.0.20
xdebug.remote_port=9000
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_enable_trigger_value=PHPSTORM
xdebug.profiler_output_dir=/var/www/html/htdocs/var
xdebug.trace_enable_trigger=1
xdebug.trace_enable_trigger_value=PHPSTORM
xdebug.trace_output_dir=/var/www/html/htdocs/var
xdebug.remote_log=/var/www/html/htdocs/var/log/xdebug.log
zend_extension=/usr/lib/php/20151012/xdebug.so
我已经安装了 Docker PHP7 FPM 模块和 xDebug。我用 pecl install xdebug
安装了它。
xdebug 正在FPM 和CLI 中加载,我已经将相应的文件正确放置在fpm 和cli 文件夹中。我可以验证它是否加载。
我已经启用了日志并且里面有这个块:
Log opened at 2019-02-08 08:12:24
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Remote address found, connecting to 127.0.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/htdocs/index.php" language="PHP" xdebug:language_version="7.0.24-1+ubuntu16.04.1+deb.sury.org+1" protocol_version="1.0" appid="16" idekey="PHPSTORM"><engine version="2.6.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2019-02-08 08:12:24
所以,logstell 告诉我连接成功。
在 PHPStorm 中我设置了 DBGp:
IDE 关键词:PHPSTORM
主机:172.55.0.1
端口:9000
我做错了什么?
这一行显示了问题所在
I: Remote address found, connecting to 127.0.0.1:9000.
它正在尝试远程连接回 127.0.0.1
,容器内部将是容器本身,而不是您的机器主机。当重新连接打开时,远程主机被忽略:
This setting is ignored if xdebug.remote_connect_back is enabled.
https://xdebug.org/docs/all_settings#remote_host
您应该禁用 remote_connect_back
并明确指定远程主机:
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal
xDebug 已安装,日志已启用,验证正常,日志告诉我 xdebug 可以连接到客户端;但是 - 与 IDE
没有联系- 在 Docker 中使用 PHP7 安装了 xDebug
- 在环境中添加了相应的ini文件
- 设置断点
- 在 CLI 和 FPM 中验证 xDebug
20-xdebug.ini:
xdebug.idekey=PHPSTORM
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_host=172.55.0.20
xdebug.remote_port=9000
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=0
xdebug.profiler_enable_trigger_value=PHPSTORM
xdebug.profiler_output_dir=/var/www/html/htdocs/var
xdebug.trace_enable_trigger=1
xdebug.trace_enable_trigger_value=PHPSTORM
xdebug.trace_output_dir=/var/www/html/htdocs/var
xdebug.remote_log=/var/www/html/htdocs/var/log/xdebug.log
zend_extension=/usr/lib/php/20151012/xdebug.so
我已经安装了 Docker PHP7 FPM 模块和 xDebug。我用 pecl install xdebug
安装了它。
xdebug 正在FPM 和CLI 中加载,我已经将相应的文件正确放置在fpm 和cli 文件夹中。我可以验证它是否加载。
我已经启用了日志并且里面有这个块:
Log opened at 2019-02-08 08:12:24
I: Checking remote connect back address.
I: Checking header 'HTTP_X_FORWARDED_FOR'.
I: Remote address found, connecting to 127.0.0.1:9000.
I: Connected to client. :-)
-> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/htdocs/index.php" language="PHP" xdebug:language_version="7.0.24-1+ubuntu16.04.1+deb.sury.org+1" protocol_version="1.0" appid="16" idekey="PHPSTORM"><engine version="2.6.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[http://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2018 by Derick Rethans]]></copyright></init>
-> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="http://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
Log closed at 2019-02-08 08:12:24
所以,logstell 告诉我连接成功。
在 PHPStorm 中我设置了 DBGp: IDE 关键词:PHPSTORM 主机:172.55.0.1 端口:9000
我做错了什么?
这一行显示了问题所在
I: Remote address found, connecting to 127.0.0.1:9000.
它正在尝试远程连接回 127.0.0.1
,容器内部将是容器本身,而不是您的机器主机。当重新连接打开时,远程主机被忽略:
This setting is ignored if xdebug.remote_connect_back is enabled.
https://xdebug.org/docs/all_settings#remote_host
您应该禁用 remote_connect_back
并明确指定远程主机:
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal