Coder Social home page Coder Social logo

phpstorm-url-handler's Issues

phpstorm.sh is not founded

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.

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
fi

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 ๐Ÿ‘Œ

Opens wrong path (prefixed with home directory)

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

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&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

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.

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}"
else
    /usr/bin/env pstorm --line "${line}" "${file}"
fi

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
		/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

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 ?

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.