I’m a big terminal fan, and I’m also a PHP developer.  Last month, I switched from Netbeans to PHPStorm for a full-fledged PHP IDE1.  Often, I’m in the terminal, and find it natural to open a file in PHPStorm from there.  Awkwardly, you need to use the full path of the file to do this.  That means, if I’m in /var/www/some_client/some_site/htdocs/resources/web/ I have to type this command just to open index.php in that directory:

phpstorm /var/www/some_client/some_site/htdocs/resources/web/index.php

Ugh. Far too much typing. I looked for a shell integration plugin, or a setting under File -> Settings, where PHP Storm crams thousands of options.2

It turns out, I was just looking in the wrong place. You have to set up this feature, but it’s dead simple. Open Tools -> Create Command-Line Launcher….

PHP Storm Command Line setup menu option

Next, pick a name for the executable and a path to place the shortcut in.  The name is the command you’ll type to run phpstorm from the terminal, so you can make it shorter for even less typing!  The path should be in your system shell’s $PATH variable; PHPStorm’s default is probably what you want if you don’t know what this means.

PHP Storm Command Line Config dialog

PHP Storm Command Line Config dialog

Hit OK to save.  If your user doesn’t have acces to that Path, you may be prompted to enter a password for the system root user.

Once you’re done, you can navigate into any directory and run your command to open files directly in PHP Storm.

pstorm somefile.php

Your life will be 30% better from now on.

  1. mostly on account of IdeaVIM’s excellent VIM emulation.  It’s not complete, but netbeans’ version is vastly inferior.
  2. For a while, I resorted to a slightly shorter workaround, typing “phpstorm `pwd`/index.php” in these situations… still too much typing