VSCode无法连接到Xdebug



我试图在docker容器中设置Xdebug步骤调试器,以便能够连接到我的docker容器。

这是我的项目中.vscode目录中launch.json的配置片段:

{
"name": "Xdebug",
"type": "php",
"request": "launch",
"hostname": "127.0.0.1",
"port": 9000,
"pathMappings": {
"/var/www/html/": "${workspaceFolder}/code/",
},
},

这是我的docker-compose.yml:的代码段

services: 
webserver:
container_name: webserver_orderlinev3
build: webserver
ports: 
- 8080:80
- 9000:9000
volumes: 
- ./code:/var/www/html
- ./webserver/php-ini-overrides.ini:/usr/local/etc/php/conf.d/php-ini-overrides.ini
- ./webserver/phpsessions:/var/www/phpsessionfiles
- ./xdebuglog:/tmp/xdbglog
extra_hosts:
- host.docker.internal:host-gateway
environment:
- XDEBUG_MODE=debug,develop,coverage,profile,trace

以及那些我的php.ini覆盖的地方


[session]
session.save_handler=files
session.save_path="/var/www/phpsessionfiles"
[xdebug]
xdebug.client_port=9000
xdebug.mode=off
xdebug.discover_client_host=on
xdebug.client_host = host.docker.internal
xdebug.remote_connect_back=0
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.start_with_request = yes
xdebug.log=/tmp/xdbglog/xdebug_remote.log

因为这是xdebug.log 的日志输出

[17] Log opened at 2022-10-25 16:22:46.248594
[17] [Step Debug] INFO: Checking remote connect back address.
[17] [Step Debug] INFO: Checking header 'HTTP_X_FORWARDED_FOR'.
[17] [Step Debug] INFO: Checking header 'REMOTE_ADDR'.
[17] [Step Debug] INFO: Client host discovered through HTTP header, connecting to 172.29.0.1:9000.
[17] [Step Debug] WARN: Creating socket for '172.29.0.1:9000', poll success, but error: Operation now in progress (29).
[17] [Step Debug] WARN: Could not connect to client host discovered through HTTP headers, connecting to configured address/port: host.docker.internal:9000. :-|
[17] [Step Debug] INFO: Connected to debugging client: 172.29.0.1:9000 (from REMOTE_ADDR HTTP header), host.docker.internal:9000 (fallback through xdebug.client_host/xdebug.client_port). :-)
[17] [Step Debug] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/orderline/api/index.php" language="PHP" xdebug:language_version="8.0.24" protocol_version="1.0" appid="17"><engine version="3.1.5"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2022 by Derick Rethans]]></copyright></init>
[17] [Step Debug] <- feature_set -i 1 -n max_children -v 100
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="1" feature="max_children" success="1"></response>
[17] [Step Debug] <- feature_set -i 2 -n max_data -v 8192
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="feature_set" transaction_id="2" feature="max_data" success="1"></response>
[17] [Step Debug] <- breakpoint_set -i 3 -t exception -x "Notice"
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="3" id="170008"></response>
[17] [Step Debug] <- breakpoint_set -i 4 -t exception -x "Warning"
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="4" id="170009"></response>
[17] [Step Debug] <- breakpoint_set -i 5 -t exception -x "Error"
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="170010"></response>
[17] [Step Debug] <- breakpoint_set -i 6 -t exception -x "Exception"
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="170011"></response>
[17] [Step Debug] <- breakpoint_set -i 7 -t exception -x "Fatal error"
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="170012"></response>
[17] [Step Debug] <- breakpoint_set -i 8 -t exception -x "Parse error"
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="170013"></response>
[17] [Step Debug] <- breakpoint_set -i 9 -t exception -x "Unknown error"
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="170014"></response>
[17] [Step Debug] <- run -i 10
[17] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="10" status="stopping" reason="ok"></response>
[17] Log closed at 2022-10-25 16:22:46.308352

我不知道为什么它实际上不起作用。

主机端口到来宾端口重定向似乎正在工作,因为我可以通过localhost:8080连接到Web服务器我现在在YouTube上看了几个关于这个话题的教程,但我不知道自己做错了什么。

Xdebug似乎连接到docker.host.internal,但网关似乎阻止了这一点——尽管我甚至为了测试而关闭了防火墙(再次打开(。

有docker和Xdebug经验的人可以帮助我吗?我真的很感激。

附言:我没有使用任何VPN连接——正是因为这个原因,它被禁用了。

谢谢,它终于开始运行了如果没有@LazyOne,我会在这里再呆一段时间,特别感谢他<3

这是配置

[session]
session.save_handler=files
session.save_path="/var/www/phpsessionfiles"
[xdebug]
#xdebug.client_port=9003
#xdebug.mode=off
#xdebug.discover_client_host=on
xdebug.client_host = host.docker.internal
xdebug.start_with_request = yes
xdebug.log=/tmp/xdbglog/xdebug_remote.log

docker-compose.yml

version: "3.2"


services: 
webserver:
container_name: webserver_orderlinev3
build: webserver
ports: 
- 8080:80
volumes: 
#setup virtual webroot
- ./code:/var/www/html/
# setup react
- ./react_build:/var/www/html/orderline/
#setup virtual webroot
- ./code/orderline/api:/var/www/html/orderline/api
#php.ini overrides
- ./webserver/php-ini-overrides.ini:/usr/local/etc/php/conf.d/php-ini-overrides.ini
#php sessions
- ./webserver/phpsessions:/var/www/phpsessionfiles
#xdebug
- ./xdebuglog:/tmp/xdbglog
extra_hosts:
- host.docker.internal:host-gateway
environment:
- XDEBUG_MODE=debug,develop,coverage,profile,trace
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Xdebug",
"type": "php",
"request": "launch",
"hostname": "127.0.0.1",
"port": 9003,
"pathMappings": {
"/var/www/html": "${workspaceFolder}/code",
},
},
]
}

相关内容

  • 没有找到相关文章

最新更新