print PhpStorm Command Tool Config

There are a variety of IDEs available for PHP development ranging from free to expensive. Perhaps the most well known (in no particular order) are Zend Studio, Nusphere PHPEd and Eclipse PDT. More recently, Netbeans has added PHP support (from 6.5) and in the latest version (6.9) it is looking very promising.

Now there is another alternative in the paid-for market - PhpStorm from Jetbrains. PhpStorm is built on Jetbrains IntelliJ idea platform - a Java development IDE. The first version saw a final release in April 2010. It is a cross-platform PHP IDE and is already looking pretty feature rich. The latest stable version is 1.0.2, however a 2.0 is in development with an Early Access Preview (link may expire once 2.0 is released) edition available for download.

In the latest 2.0 EAP (103.57 at the time of writing) is support for Command Line Tools for frameworks including the ability to create custom tools through an XML document. To save you the hardwork, we've written one specifically for Scorpio! It covers all the main tools from the main scorpio.php CLI script.

To make use of it, download Scorpio (0.4.4 or above) and create a new Scorpio based project from it in PhpStorm 2. You will need the main libraries and tools scripts. Then in your PhpStorm Project, go to "File" -> "Settings" and select "Command Line Tool Support".

Screenshot showing PhpStorm - Settings - Command Line Tool Support

Next select "Custom Framework" click OK. In the next box set the title to Scorpio, the tool path to "tools/" the shortname to "scorpio" (lowercase) and enter a description if you want to. The sharp eyed amongst you will spot the mistake in the screenshot (scorpio.php - not - oops!).

Screenshot showing PhpStorm - Settings - Command Line - Framework Settings

Click OK and the entry will appear in the list of Command Line Tools and the definition file will open in the background.

Screenshot showing PhpStorm - Settings - Command Line - Active Frameworks

Close the settings dialogue and then copy and paste the pre-built Scorpio.xml file you downloaded previously, completely over the top.

Screenshot showing the edited config file

Save the changes.

Now you can go to "Tools" and "Run Command".

Screenshot showing PhpStorm - Tools - Run Command Box

Start typing "scorpio" in the dialogue box and the various commands and tooltips should appear.

Screenshot showing PhpStorm - Command Line - scorpio auto-complete options

Complete the details and press enter to run the command. If all is correct, the Command Line Output will open and your request should be processed.

Screenshot showing PhpStorm - Run Command - Results - A basic site listing


Windows Users

To get this to work in Windows, you will need to create a scorpio.bat file and set it to execute the main scorpio.php file via your command line version of PHP (e.g. c:\wamp\bin\php5.3.2\bin\php.exe c:\path\to\project\tools\scorpio.php). Then change the tool path to point to tools\scorpio.bat instead. It may be useful to add the PHP executable to your Windows path (under Advanced Settings accessed via the Control Panel -> System).


Scorpio.xml (PhpStorm 2.0 Command Line Descriptor)

<  1  >