sanduhrs / phpstorm-url-handler Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Using latest phpstorm, dont remember how did I installed it. phpstorm.sh is located in
~/.local/share/JetBrains/Toolbox/apps/PhpStorm/ch-0/173.4548.32/bin/phpstorm.sh
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}"
fi
to
/usr/bin/env ~/.local/share/JetBrains/Toolbox/apps/PhpStorm/ch-0/173.4548.32/bin/phpstorm.sh --line "${line}" "${file}"
Adding this issue just in case if somebody else cant make it work too.
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
fi
For other platforms exists https://github.com/aik099/PhpStormProtocol library with different prefix pstorm://
.
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 ๐
Looks like the .desktop file opens relative path, instead of the absolute one.
When opening:
phpstorm://open?file=%2Fhome%2Fuser%2Fwww%2Fapigil%2Fzf%2Fmodule%2FApplication%2Fsrc%2FController%2FIndexController.php&line=38
In PhpStorm i get the following error:
File not found:
/home/user/./%2Fhome%2Fuser%2Fwww%2Fapigil%2Fzf%2Fmodule%2FApplication%2Fsrc%2FController%2FIndexController.php&line=38
(note the /home/user/./
prefix added)
Is there any way I can fix this?
Latest Ubuntu,
Latest PhpStorm
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&line=@line
# phpstorm://open?file=@file&line=@line
#
# @license GPL
# @author Stefan Auditor <[email protected]>
# @author Petr 'PePa' Pavel <[email protected]>
input=${1}
# https://stackoverflow.com/a/37840948/465732
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
arg=$(urldecode "$input")
pattern=".*file(:\/\/|\=)(.*)&line=(.*)(&project=(.*))?"
# 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
basePath="/home/myusername/projects"
declare -A paths
paths["project5.6"]="projectdirname/php-5.6"
file=$(echo "${file}" | sed -r "s#/var/www/app#${basePath}/${paths[$project]}#")
fi
# 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}"
fi
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.
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}"
else
/usr/bin/env pstorm --line "${line}" "${file}"
fi
I run PhpStorm v171.4163.3 on linux64 + kde.
My browser's Firefox DevEd.
As the bins include
tree /usr/local/phpstorm/bin
/usr/local/phpstorm/bin
โโโ [root 223] format.sh
โโโ [root 23072] fsnotifier
โโโ [root 29648] fsnotifier64
โโโ [root 26453] fsnotifier-arm
โโโ [root 10806] idea.properties
โโโ [root 274] inspect.sh
โโโ [root 3449944] libyjpagent-linux64.so
โโโ [root 3679036] libyjpagent-linux.so
โโโ [root 2236] log.xml
โโโ [root 329] phpstorm64.vmoptions
โโโ [root 9211] phpstorm.png
!!! โโโ [root 6955] phpstorm.sh
โโโ [root 337] phpstorm.vmoptions
โโโ [root 410] printenv.py
โโโ [root 590] restart.py
I launch phpstorm as
kdesu "/usr/local/phpstorm/bin/phpstorm.sh" %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/phpstorm.sh --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?
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 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.