How to xdebug when your PHPStorm runs with xserver inside WSL2, but you use Docker Desktop on windows 10

the hard part (networking)

wsl hostname -I
netsh interface portproxy set v4tov4 listenport=9000 listenaddress=0.0.0.0 connectport=9000 connectaddress=172.26.153.65

The easy part

pecl install xdebug && docker-php-ext-enable xdebug
php --ini
output from php — ini
[xdebug]
xdebug.mode=debug
xdebug.client_host=host.docker.internal
xdebug.client_port=9000
xdebug.start_with_request=yes

Path mappings

Host does not matter, map your local path to the one in docker
myservice:
image: xxx
environment:
PHP_IDE_CONFIG: "serverName=web"

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store