我正在尝试在 docker 容器中设置 Xdebug 3 并在 Visual Studio Code 中捕获断点。
我的 xdebug 日志:
[7] Log opened at 2021-02-16 16:12:12.027862
[7] [Step Debug] INFO: Checking remote connect back address.
[7] [Step Debug] INFO: Checking header 'HTTP_X_FORWARDED_FOR'.
[7] [Step Debug] INFO: Checking header 'REMOTE_ADDR'.
[7] [Step Debug] INFO: Client host discovered through HTTP header, connecting to 172.26.0.1:9099.
[7] [Step Debug] INFO: Connected to debugging client: 172.26.0.1:9099 (from REMOTE_ADDR HTTP header). :-)
[7] [Step Debug] -> <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.27" protocol_version="1.0" appid="7" idekey="VSCODE"><engine version="3.0.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2021 by Derick Rethans]]></copyright></init>
[7] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[7] [Step Debug] WARN: 2021-02-16 16:12:12.039287: There was a problem sending 179 bytes on socket 6: Broken pipe.
xdebug.ini 配置:
[xdebug]
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so
xdebug.client_port = 9099
xdebug.client_host = host.docker.internal
xdebug.idekey = VSCODE
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.discover_client_host = true
xdebug.log = /var/tmp/xdebug.log
Visual Studio 代码配置 (json.config)
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9099,
"log": true,
"externalConsole": false,
"pathMappings": {
"/var/www/public": "${workspaceFolder}",
},
"ignore": [
"**/vendor/**/*.php"
]
},
]
}
我将感谢您的帮助,我已经想不出为什么它不起作用了。