aik099/PhpStormProtocol

Mac pstorm in usr/local/bin

Closed this issue · 28 comments

how did you create this or was it done by the ide?

Created what, pstorm file? Yes this was done by IDE and I've explained in manual how to do this too.

When im using this handler it just brings my phpstorm to the foreground but doesnt open any files or go to any lines any ideas?

It's good, that PhpStorm is opened at all, because this proves that there is /Applications/PhpStorm.app and you have pstrom script. I personally have 2 of them with different names.

Also note, that links, that you're clicking must have absolute path to file, that will be opened on Mac. For example I have webserver running in Virtual Machine and I need to map paths in my web application to allow building paths to Mac, where PhpStorm will process them.

i have absolute paths im trying to use your handler with whoops (nice combo) this is the exact url it has on a dummy example project

pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php&line=18

does pstorm /Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php:18 command open the file?

yep thats the odd part. running pstorm in the command line works perfectly.

Does pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php&line=18 url (when copy/pasted to browser tab and executed) open PhpStorm with a file?

Maybe it doesn't work in one particular browser and works with others. I've tested with Firefox and Chrome. On first run I presented with a dialog asking me "do you trust PhpStormProtocol.app to open this url". After answering "yes" a file was opened. But what's important is to have project already opened in PhpStorm before trying to use that link.

What happens if you call https://github.com/aik099/PhpStormProtocol/blob/master/PhpStorm%20Protocol.app/Contents/bin/parse_url.sh script with an url given? It surely does something and maybe fails for unknown reason.

the project is open and i did get the protesting box about trusting the app which i accepted and no pasting the link in the browser doesnt work either in safari or chrome. Chrome just wants to do a google search.

when running that i get this

Clarks-MacBook-Pro:bin clarktomlinson$ ./parse_url.sh pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php&line=18
[1] 8706
Clarks-MacBook-Pro:bin clarktomlinson$ ./parse_url.sh pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php&line=18
[2] 8707
[1] Done ./parse_url.sh pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php
Clarks-MacBook-Pro:bin clarktomlinson$ ./parse_url.sh pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php&line=18
[3] 8708
[2] Done ./parse_url.sh pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php
Clarks-MacBook-Pro:bin clarktomlinson$ ./parse_url.sh pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php&line=18
[4] 8709
[3] Done ./parse_url.sh pstorm://open/?url=file:///Users/clarktomlinson/Sites/Work/Wordpress-Installs/INSPComposer/wp-content/themes/twentytwelve/index.php

thats running it a few times also thanks for your assitance btw

How are you building url (in your app), that is to be processed by PhpStormProtocol? Are you properly escaping url that goes to url parameter? Using urlencode (or rawurlencode) for example?

i wasnt but when i attempted to just now i still get nothing

Try using textmate url scheme (http://manual.macromates.com/en/using_textmate_from_terminal.html):

txmt://open/?url=file://~/.bash_profile&line=11&column=2

This way you can test if you properly escaping url.

still nothing on my end

Doesn't work even with TextMate?

oh no text mate works fine

Clark Tomlinson
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Wednesday, June 19, 2013 at 11:35 AM, Alexander Obuhovich wrote:

Doesn't work even with TextMate?


Reply to this email directly or view it on GitHub (#2 (comment)).

My best bet is on incorrect url escaping. Maybe TextMate solved that problem somehow. I don't have any urls, that doesn't work to test with.

I think, that parse_url.sh isn't really parsing any filename from given url and that's why it doesn't work.

If you wish to debug further you can display parsed filename & line number instead of giving them to pstrom. From there you can either get empty string or some extra symbols, that are in fact preventing pstorm script from working with them.

how could i do that my bash skills are all but null but that would be very helpful

Here is what you have now:

#!/bin/sh
URL="$1"
REGEX="^pstorm://open/\?url=file://(.*)&line=(.*)$"

if [[ $URL =~ $REGEX ]]; then
    /usr/local/bin/pstorm "${BASH_REMATCH[1]}:${BASH_REMATCH[2]}"
fi

Here is what you need to have:

#!/bin/sh
URL="$1"
REGEX="^pstorm://open/\?url=file://(.*)&line=(.*)$"
echo "URL: $URL"

if [[ $URL =~ $REGEX ]]; then
    echo "MATCH: ${BASH_REMATCH[1]}:${BASH_REMATCH[2]}"
else
    echo "NO MATCH"
fi

Could you give an example that works for you so i can test please

Clark Tomlinson
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)

On Wednesday, June 19, 2013 at 11:48 AM, Alexander Obuhovich wrote:

Here is what you have now:
#!/bin/sh URL="$1" REGEX="^pstorm://open/?url=file://(.)&line=(.)$" if [[ $URL =~ $REGEX ]]; then /usr/local/bin/pstorm "${BASH_REMATCH[1]}:${BASH_REMATCH[2]}" fi

Here is what you need to have:
#!/bin/sh URL="$1" REGEX="^pstorm://open/?url=file://(.)&line=(.)$" echo "URL: $URL" if [[ $URL =~ $REGEX ]]; then echo "MATCH: ${BASH_REMATCH[1]}:${BASH_REMATCH[2]}" else echo "NO MATCH" fi


Reply to this email directly or view it on GitHub (#2 (comment)).

This is copy/pasted from a link, clicking on which opens PhpStorm with that file: pstorm://open/?url=file:///Volumes/web/d/in-portal.52x/core/kernel/application.php&line=303.

In my debugger I have following HTML that makes that link:
<a href="pstorm://open/?url=file:///Volumes/web/d/in-portal.52x/core/kernel/application.php&line=303">application.php:303</a>.

It seems, that even don't escape url at all and it still works :)

@th3fallen, I've found that this no longer works with PhpStorm 6.0.3. But it was working with PhpStorm 5.0.4.

I guess something changed on PhpStorm side.

ha! im not crazy! glad to know its not me being incompetent.

Also after upgrading to OSX 10.8.4 I can't get my app to work anymore, because it's throwing an error, when executed by double clicking PhpStorm Protocol in applications.

Any decent applescript debugging tools out there, that you might recommend? When I set file url in a local variable and test it all works. But it comes in reality through protocol handler it doesn't work.

using OSX 10.9.2 with phpStorm 7.1.3
I installed the app and launched it

on the command line using $ pstorm /Users/lsmith/htdocs/cmf-sandbox/app/AppKernel.php works as expected but opening the URL pstorm://open/?url=file:///Users/lsmith/htdocs/cmf-sandbox/app/AppKernel.php&line=10 nothing happens.

I guess in my original solution (that doesn't involve LinCastor) something isn't correctly escaped between AppleScript and Shell Script. If you can fix it, then PR is welcome.

Closing because LinCastor solution for Mac users is clearly superior, then current implementation.