问题
I work on PHP application and I want to debug my website. I'm working on IDE VSCode on Windows 10. I use Docker to launch my website in WSL2.
I have configured XDebug in my php-fpm:7.3 container.
root@00376c075cd3:/var/www# php -version
PHP 7.3.18 (cli) (built: May 15 2020 13:33:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.18, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
On VSCode, I have configured my launch.json file (with extension phpdebug from
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000,
"pathMappings": {
"/var/www": "${workspaceFolder}/src"
}
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9000,
"pathMappings": {
"/var/www": "${workspaceFolder}/src"
}
}
]
}
I see in XDebug log that it's connected.
[6] Log opened at 2020-11-24 16:48:10
[6] I: Connecting to configured address/port: localhost:9000.
[6] I: Connected to client. :-)
[6] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/index.php" language="PHP" xdebug:language_version="7.3.18" protocol_version="1.0" appid="6" idekey="VSCODE"><engine version="2.9.8"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>
[6] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[6] Log closed at 2020-11-24 16:48:10
I put breakpoints on my index.php file: breakpoints
But my request is not stopped in VSCode.
Can you please help me to finish my XDebug configuration?
Thank you for your help.
Regards, Anthony
回答1:
Thank you @LazyOne. I put your comment as answer. :-)
" Connecting to configured address/port: localhost:9000. It is expected with this kind of settings. Based on Xdebug log you must have connected to the php-fpm that runs inside your docker/WSL2 (it also uses 9000 port by default). You need to use correct IP of your host OS (so Xdebug can connect FROM your docker/WSL2 TO you VSCode that runs on Windows). I suggest checking some ready-made guides on how to configure Xdebug/Docker image in such cases. You may also check here for possible hints: learnxdebug.com "
来源:https://stackoverflow.com/questions/64991324/vscode-xdebug-connected-to-client-but-break-points-does-not-work