Skip to content

Instantly share code, notes, and snippets.

@yireo
Last active July 30, 2022 17:35
Show Gist options
  • Save yireo/73242ade36268622d12a to your computer and use it in GitHub Desktop.
Save yireo/73242ade36268622d12a to your computer and use it in GitHub Desktop.
Open up XDebug links in PhpStorm under Gnome

Open up XDebug links in PhpStorm under Gnome

Configure XDebug in PHP

Open up your XDebug file (possibly /etc/php.d/15-xdebug.ini) and configure XDebug:

xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.file_link_format="phpstorm://open?file=%f&line=%l"

Restart your webserver to activate XDebug.

Create a desktop file for PhpStorm

Create a file /usr/share/applications/phpstorm.desktop with the following contents (where PHPSTORM_HOME is actually replaced with the path to your PhpStorm files). You can also use your own personal folder ~/.local/share/applications/ instead.

[Desktop Entry] 
Terminal=false
Name=PhpStorm
Exec=PHPSTORM_HOME/bin/phpstorm.sh %u
Type=Application
Icon=PHPSTORM_HOME/bin/webide.png
X-MultipleArgs=True
MimeType=application/phpstorm;x-scheme-handler/phpstorm;
Encoding=UTF-8
Categories=Development;

Run the following command to install this new file:

sudo update-desktop-database

Modify the PhpStorm script

Open up your PHPSTORM_HOME/bin/phpstorm.sh script and add the following to the top:

url="$1"
if [ ! -z "$1" ]
    then
        url=${url#*file=}
        line=${url##*line=}
        file=${url%%&line*}
        file=${file//\%2F/\/}
        set -- "--line $line $file"
fi

This will make sure that the input-parameters given by XDebug are parsed and turned into the arguments that PhpStorm actually expects.

Works for me.

@rahilwazir
Copy link

@yireo What does it mean by XDebug links?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment