【发布时间】:2020-02-01 04:58:58
【问题描述】:
我正在尝试使用 docker、X-debug2.7.2、centos 和 php7.3.7 调试 Laravel 应用程序,但是不遵守断点。使用以下消息更新日志。
[41] Log opened at 2019-10-02 21:09:33
[41] I: Connecting to configured address/port: docker.for.win.localhost:9000.
[41] I: Connected to client. :-)
[41] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/public/index.php" language="PHP" xdebug:language_version="7.3.6" protocol_version="1.0" appid="41"><engine version="2.7.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init>
[41]
[41] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[41]
[41] Log closed at 2019-10-02 21:09:34
XDebug 配置
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 0
xdebug.remote_enable = 1
xdebug.remote_host = docker.for.win.localhost
xdebug.remote_log = "/tmp/xdebug.log"
xdebug.remote_port = 9000
Vscode 配置
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www": "${workspaceRoot}"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
"pathMappings": {
"/var/www": "${workspaceRoot}"
}
}
更新
经过多次尝试,我已将 x-debug 配置中的 remote_host 设置为我本地机器的 IP,并且它工作正常。
对于那些相信别名 host.docker.internal 会起作用的人来说,它没有。所以我所做的是为 remote_host 键设置一个虚构的名称,并在 docker-compose 中将其配置为具有本地 IP 的额外主机。
我认为这不是一个好的解决方案,因为使用此配置文件的每个人都需要在本地进行更改。所以我想知道你们是否有更好的解决方案。
【问题讨论】:
-
情况不一样。在创建这个之前,我已经尝试了引用主题中提到的所有步骤。我不确定操作系统对这个问题的影响,但是,我之前使用的直接来自 PHP docker hub 存储库的图像工作正常,另一方面,使用 centOS 的图像没有。
标签: php docker visual-studio-code centos xdebug