Some useful commands to get xdebug running with docker on wsl2
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.idekey = VSCODE
; "hostname": "0.0.0.0" // add this in your vscode launch.json if xdebug.remote_host = host.docker.internal
xdebug.remote_host = host.docker.internal
xdebug.remote_connect_back = 0
xdebug.default_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_port = 9000
xdebug.remote_log=/var/log/php/xdebug.log
{
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9000,
"log": true,
"pathMappings": {
"/var/www/sites/prod/docroot":"${workspaceRoot}",
},
"hostname": "0.0.0.0" //add this if xdebug.remote_host = host.docker.internal
}
]
}
- use this on the host to see if vscode xdebug is running on 9000. Run these commands after you have started debug session in VSCode
lsof -PiTCP -sTCP:LISTEN | grep 9000
- use this inside php container to check if port 9000 is open
nc -zv host.docker.internal 9000