Coder Social home page Coder Social logo

phpstorm-url-handler's Introduction

PhpStorm URL Handler

This package contains a launcher to open files in PhpStorm at the defined line number and an associated desktop file that conforms to the Desktop Entry Specification for use in Gnome and KDE desktop environments.


The executable phpstorm or pstorm must be in your $PATH. If it is not, either add the install location to your path

export PATH="/path/to/phpstorm/bin/$PATH"

or symlink it to one of /usr/bin or /usr/local/bin - which already should be in your $PATH. Use sudo if needed

ln -s /path/to/phpstorm/bin/ /usr/bin/phpstorm

Then copy the actual handler to your $PATH and make it executable. Use sudo if needed

cp phpstorm-url-handler /usr/bin/phpstorm-url-handler
chmod +x /usr/bin/phpstorm-url-handler

Install the .desktop file to register the mime-types. Use sudo if needed

desktop-file-install phpstorm-url-handler.desktop


It can be used to open files at the specified line from within the browser by placing a link of the following kind in the markup:

$file = "/path/to/filename.php";
$line = 35;
print "<a href='phpstorm://open?url=file://$file&line=$line'>Open with PhpStorm</a>";
// Alternate Syntax to match PhpStorm 8 for the Macintosh
print "<a href='phpstorm://open?file=$file&line=$line'>Open with PhpStorm</a>";

Command-line usage

./phpstorm-url-handler "phpstorm://open?url=file://${FILE}&line=${LINE}"

This alternative syntax matches the format used by PhpStorm 8 for the Macintosh for cross-platform compatibility.

./phpstorm-url-handler "phpstorm://open?file=${FILE}&line=${LINE}"

This script is used in the ARCH linux package to be found at



phpstorm-url-handler's People


sanduhrs avatar leogout avatar harcod avatar agentsib avatar XMarat avatar


Nicolas Cabot avatar  avatar Jurjen Beukenhorst avatar Noys avatar Maksym Haiduk avatar Pavel avatar  avatar Ole Jørgen Brønner avatar Robin Dvořák avatar Sabyrzhan avatar Kirill Lubynets avatar  avatar Can Vural avatar  avatar Szymon Kamiński avatar M.H.Zarei avatar Krasimir Todorov avatar Armando Lüscher avatar Stéphane Sauvaget avatar Weijun Yu avatar  avatar Турбоост avatar Adrian Nürnberger avatar Ginbert avatar  avatar Gary PEGEOT avatar Alexander Galitsky avatar  avatar Roger Guasch avatar  avatar Vladimir Kovalenko avatar Logan Esenther avatar Robert Wilde avatar Mikhail Kirillov avatar Philippe M. avatar Marcel Kuhmann avatar Markus Staab avatar Stijn Van Campenhout avatar  avatar Fayez NACCACHE avatar Lloric Mayuga Garcia avatar Kartulin avatar Marcin Zawadzki avatar Oleg Dyachenko avatar  avatar Rodrigo Pedra Brum avatar Xakki avatar fullbl avatar Ingo Steinke avatar Matthias Morin avatar Sylvain Bordier avatar Marius Palade avatar Davi Alexandre avatar Anthony Axenov avatar 锅锅锅de1T avatar SMITH Emmanuel avatar Bernhard Hörmann avatar Андрей avatar Aleksey avatar Janko avatar Drakakis George avatar Cezar Popa avatar Jarkko avatar Benoit GALATI avatar  avatar Andro avatar Bilal YILMAZ avatar Abraham Wind avatar Evgeniy Rychkov avatar Nicolas Bonnet avatar Guillaume MOREL avatar Michel Tomas avatar Michaël Jacobs avatar  avatar  avatar Matheus Faustino avatar Jeroen van der Kolff avatar فرهاد روحانی مقدس avatar Cocolabs avatar Martin Franc avatar GT avatar Piero Recchia avatar Tom Van Looy avatar Aleksandar Mitic avatar  avatar Andy Roid avatar Jorge Casas avatar Sébastien Monterisi avatar phY avatar Thomas Verwijst avatar Michał Lüth avatar Evgeny avatar Вадим Дунькин avatar Viacheslav Nozhenko avatar Laszlo Lang avatar  avatar Hristo Hristov avatar Ivan avatar Adam Gąsowski avatar Moshe Kolodny avatar


Stefan Auditor avatar Martin Hasoň avatar David Darrell avatar hacfi avatar  avatar James Cloos avatar Benoit GALATI avatar Can Vural avatar Alexandru Busuioc avatar  avatar

phpstorm-url-handler's Issues

Opens wrong path (prefixed with home directory)

Looks like the .desktop file opens relative path, instead of the absolute one.

When opening:


In PhpStorm i get the following error:

File not found:


(note the /home/user/./ prefix added)

Is there any way I can fix this?

Latest Ubuntu,
Latest PhpStorm

Doesn't work for me

Doesn't work for me.
The reason is that Symfony profiler generates link without "line" in address, so, regular expression doesn't work properly.

I wrote something like this
(.*?)file(\:\/\/|\=)(.*?)(&line=(\d+))?$ , it works here, but it isn't work in sed expression .
Somebody know why Symfony profiler stoped generate lines in this one ?

stopped working, terminal true fixes it?

Everything worked for a few months, but suddenly it stopped working.
(ubuntu 16.04 LTS)

I managed to "fix" it by editing phpstorm-url-handler.desktop and changing to Terminal=true, then run sudo desktop-file-install phpstorm-url-handler.desktop and sudo update-desktop-database again, and now everything works.

If I leave everything unchanged (from current repo) and only change that true/false I can toggle between it working and not working. Not sure why. It does not seem like it should make a difference. I only made that change to see output and try to debug it, but apparently it had the side effect of making it work.

The downside is that I see a terminal window pop up for a second (which is a bit annoying), but at least it is working again.

Not really a neat fix, but good enough for me. Perhaps it can help someone else using this.

optional support for Docker (paths mapping) + urldecode

Here's a version that allows for passing a third parameter describing which project the file belongs to. That way a part of the path can be replaced. It also decodes slashes etc. in the path.

#!/usr/bin/env bash

# PhpStorm URL Handler
# phpstorm://open?url=file://@file&[email protected]
# phpstorm://[email protected]&[email protected]
# @license GPL
# @author Stefan Auditor <[email protected]>
# @author Petr 'PePa' Pavel <[email protected]>


function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }

arg=$(urldecode "$input")

# Get the file path.
file=$(echo "${arg}" | sed -r "s/${pattern}/\2/")

# Get the line number.
line=$(echo "${arg}" | sed -r "s/${pattern}/\3/")

# Project name for path replacement
project=$(echo "${arg}" | sed -r "s/${pattern}/\5/")

if [ -n "$project" ]; then

	declare -A paths

	file=$(echo "${file}" | sed -r "s#/var/www/app#${basePath}/${paths[$project]}#")

# Check if phpstorm|pstorm command exist.
if type phpstorm > /dev/null; then
    /usr/bin/env phpstorm --line "${line}" "${file}"
elif type pstorm > /dev/null; then
    /usr/bin/env pstorm --line "${line}" "${file}"

Transfer focus to the PhpStorm window

When the handler is triggered, manually open the window PhpStorm.
It is much more convenient to become more comfortable when you automate this process using wmctrl. I locally modified the command and now it looks like this:

if type phpstorm > /dev/null; then
    /usr/bin/env phpstorm --line "${line}" "${file}" && wmctrl -a PhpStorm
elif type pstorm > /dev/null; then
    /usr/bin/env pstorm --line "${line}" "${file}" && wmctrl -a PhpStorm

Command is pstorm or phpstorm ?

Hi, I installed a brand new PhpStorm 2017.1 and after running the installation script, I saw that the command to launch the IDE was pstorm instead of phpstorm.

I had to change it in the phpstorm-url-handler script in order to make it work.

Do you want me to add a test for this use case ?
Something like :

if type phpstorm > /dev/null; then
    /usr/bin/env phpstorm --line "${line}" "${file}"
    /usr/bin/env pstorm --line "${line}" "${file}"

phpstorm:// link's opens in new phpstorm instance, instead of using *existing* instance

I run PhpStorm v171.4163.3 on linux64 + kde.

My browser's Firefox DevEd.

As the bins include

	tree /usr/local/phpstorm/bin
		├── [root             223]
		├── [root           23072]  fsnotifier
		├── [root           29648]  fsnotifier64
		├── [root           26453]  fsnotifier-arm
		├── [root           10806]
		├── [root             274]
		├── [root         3449944]
		├── [root         3679036]
		├── [root            2236]  log.xml
		├── [root             329]  phpstorm64.vmoptions
		├── [root            9211]  phpstorm.png
!!!		├── [root            6955]
		├── [root             337]  phpstorm.vmoptions
		├── [root             410]
		└── [root             590]

I launch phpstorm as

kdesu "/usr/local/phpstorm/bin/" %f

I use kdesu so that it has root perms that I can use across multiple user-spaces. Works fine.

I've installed phpstorm-url-handler, and assigned the phpstorm:// mimetype in Firefox.

Here, phpstorm is not in my exec path. If I simply change

vi phpstorm-url-handler
-	/usr/bin/env phpstorm --line "${line}" "${file}"
+	/usr/bin/env /usr/local/phpstorm/bin/ --line "${line}" "${file}"

and click a phpstorm:// url, the link does NOT open in phpstorm. Rather I get a dialog stating ~'only one instance of phpstorm can be opened'.

How would I use the existing, opened-via-kdesu phpstorm instance and NOT attempt to spawn a new/second one?

Nothing happens when clicking phpstorm:// links

Hello there.
I've installed phpstorm-url-handler after instruction written in readme, except I needed the make the first command recursive with -r flag, and to run all 3 commands with sudo for authorization reasons. So after cloning this repo and changing my directory to it I ran :

sudo cp -r phpstorm-url-handler /usr/bin/phpstorm-url-handler
sudo desktop-file-install phpstorm-url-handler.desktop
sudo update-desktop-database

In my symfony project, in my config/packages/framework.yaml file I added :

ide: phpstorm

Under framework section. When going to symfony profiler, I see the generated phpstorm links but when clicking on them, nothing happens in firefox, and chrome is asking if I want to launch xdg-open and that's all.
I tried to stop/start built in server, clear cache just in case but I'm unable to make profiler links open phpstorm.

Note that phpstorm in launchable by CLI and that it was installed via snap. OS : Ubuntu 20.04. Phpstorm 2020.1

Thank you for your help 👌 is not founded

Using latest phpstorm, dont remember how did I installed it. is located in


it could be fixed by changing PATH folder, but I am pretty sure, that after phpstorm upgrade folder name would be changed. Not sure how to fix it, I just changed phpstorm-url-handler from

# Check if phpstorm|pstorm command exist.
if type phpstorm > /dev/null; then
    /usr/bin/env phpstorm --line "${line}" "${file}"
elif type pstorm > /dev/null; then
    /usr/bin/env pstorm --line "${line}" "${file}"


/usr/bin/env ~/.local/share/JetBrains/Toolbox/apps/PhpStorm/ch-0/173.4548.32/bin/ --line "${line}" "${file}"

Adding this issue just in case if somebody else cant make it work too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.