Last active
September 3, 2021 19:38
-
-
Save NAbdulla1/39503cada3a91cef02e78393d4c3ab57 to your computer and use it in GitHub Desktop.
After configuring the xdebug on wsl2 according to the official guide in PhpStorm website have to write the following script to generate xdebug.ini with correct HOST_IP. I execute this script every time I reboot pc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
lin_ip4=$(ip -4 address show label eth0 | grep inet | sed 's/^.*inet //' | sed 's/\/.*$//') | |
touch /tmp/foo | |
f=/tmp/foo | |
/mnt/c/Windows/System32/ipconfig.exe | sed 's/.$//' > $f | |
a=$(cat $f | grep -n WSL | sed 's/:.*$//') | |
b=$(cat $f | wc -l) | |
c=$(( $b - $a )) | |
win_ip4=$(cat $f | tail -n $c | grep IPv4 | head -n 1 | sed 's/^.* : //') | |
echo $win_ip4 #above code is from here: https://www.reddit.com/r/bashonubuntuonwindows/comments/i4m90o/how_to_know_ip_address_of_windows_within_ubuntu/ | |
echo zend_extension=\"/usr/lib/php/20190902/xdebug.so\" | sudo tee /etc/php/7.4/mods-available/xdebug.ini >/dev/null #xdebug path can differ | |
echo xdebug.remote_enable=1 | sudo tee -a /etc/php/7.4/mods-available/xdebug.ini >/dev/null | |
echo xdebug.remote_port=9012 | sudo tee -a /etc/php/7.4/mods-available/xdebug.ini >/dev/null | |
echo xdebug.remote_log=/tmp/xdebug.log | sudo tee -a /etc/php/7.4/mods-available/xdebug.ini >/dev/null | |
echo xdebug.remote_host=$win_ip4 | sudo tee -a /etc/php/7.4/mods-available/xdebug.ini >/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment