I configured Xdebug with PhpStorm in a WSL2 Debian instance.
Here is the configuration of my xdebug.ini :
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.discover_client_host=false
xdebug.client_host=${WSL_IP}
xdebug.client_port=9003
xdebug.idekey=PHPSTORM
the line xdebug.client_host=${WSL_IP}
is in another file : .bash_aliases
export WSL_IP=$(grep -E '^nameserver' /etc/resolv.conf | awk '{print $2}')
WSL_IP contain the IP of my vEthernet WSL.
In short I used this solution for dynamically get the current IP of WSL every time I reboot my computer.
The main problem is ${WSL_IP}
doesn't return the value at the line xdebug.client_host=${WSL_IP}
I even try to write in this way xdebug.client_host=$(echo $WSL_IP)
but it didn't work.
So my solution was to get the value of $WSL_IP
xdebug.client_host=${WSL_IP}
-> xdebug.client_host=[IP Value]
And it works in this way but the problem is every time the WSL IP changes, I have to update the file config in xdebug.ini with the new IP value.
Do you have a solution of why ${WSL_IP}
doesn't work in xdebug.ini?
Thanks in advance for your help.