Using PhpStorm from Command Line

I know the title is not so interesting because we all know PhpStorm can be launched from the command line just using the “pstorm” command. Like this:

But I love the word “storm” more than “pstorm”, so I did this in my .zshrc:

How do we open a directory in PhpStorm? Just like the usual:

Ah, that will open the current directory in PS 🙂

But what if the command line tool was not installed properly? What if, while upgrading, the tool broke? Or if like me, you install EAPs all the time to try out new features and the command line tool can’t find the EAP version’s path? Well, in this blog post, I will share the python script that is actually installed as the “pstorm” tool. I will also tell you what to modify in case it can’t find your PhpStorm. And of course, we will see how to install it.

So first, the python script. If it’s installed on your system, you can view the content:

Or to edit it with your preferred text editor (in my case vim):

If you don’t have the script installed, here’s mine:

If you know Python, feel free to read and understand what’s actually doing. Now, this script needs to know two things:

— The path to PhpStorm directory (where the executable is)
— The preferences directory

You should be able to find the first trying to locate where PhpStorm is installed. For the second, it’s actually platform dependent. On OS X, it’s inside the “Home” > “Library” > “Preferences” > “WebIde**” directory.

The preference directories are named with a zero appended to the major version of PhpStorm. So, for PS 7.x it’s WebIde70. For 6.x, it’s WebIde60.

Just configure the two variables in the script. Then copy it to your path, in my case, I have “~/.bin” added to my PATH. So I did this:

The last line makes it executable. Now open a new terminal and try the “pstorm” command.


2 Comments Using PhpStorm from Command Line

Leave a Reply

Your email address will not be published. Required fields are marked *