Command Line Tools in PhpStorm

PhpStorm has had support for command line tools for a while. Using the command line tools, we can invoke commands right from our IDE! We can bring up the command line tool using the Tools | Run Command… menu or with Ctrl+Shift+X (Cmd+Shift+X on Mac).

Check other video tutorials around PhpStorm.

The command line tools come with support for autocompletion of several known tools. Nothing comes for free: we have to add the tools we want to use through the IDE Settings | Command Line Tool Support pane. After adding Composer, for example, we get autocompletion on all composer commands:

From PhpStorm’s settings, the IDE Settings | Command Line Tool Support pane allows us to add support for other framework specific tools as well. For example, when working with a Symfony project, we can enable support for the symfony tool by adding it and specifying the path to where this tool resides:

The command line tools console will have autocompletion support for the Symfony tool, aliased as s.

Out of the box, PhpStorm comes with support for Composer, the Zend Framework tool (zf) and Symfony’s command line tool. What about adding autocompletion for custom tools?

Custom command line tools can be added through the IDE Settings | Command Line Tool Support pane as well. The only difference is we now have to specify the alias for the tool we wish to use as well as the path to this tool.

Of course, PhpStorm can not determine autocompletion for every custom tool we add automatically. Fortunately, we can create our own definition. From the settings dialog, click the Open definition in browser button to generate a boilerplate command line tool description.

We can now define commands, parameters and help information for our custom command line tool. Find a more detailed tutorial on our developer community website. After saving the XML file containing the description, PhpStorm will recognize the command and provide us with autocompletion for our custom command line tool.

A Gist for the above screenshot can be found here.

Please report any bugs and feature requests here, and leave questions in the comments below or in our forums!

Develop with pleasure!
– JetBrains PhpStorm Team

This entry was posted in Cool Feature and tagged , , , , , . Bookmark the permalink.

10 Responses to Command Line Tools in PhpStorm

  1. It will be nice to have auto-complete functionality for GIT.

  2. Henry Garcia says:

    Is there any way to change which php is being invoked using the command line tool. I use MAMP for web development but when I type “which php” on the command line I get “usr/bin/”. I am MAC osx 10.8

  3. Maarten Balliauw says:

    From the CommandLine Tool support dialog, remove the $PhpExecutable$ variable and change it with the PHP executable of your choice.

  4. Pingback: Web Design Digest No.5 (30 — 08 July 2013) | Splashnology.com

  5. Pingback: Zend Framework 2 Command Line Tool (ZFTool) Support | JetBrains PhpStorm Blog

  6. Pingback: Command Line Tools Based on Symfony Console (Doctrine, Laravel) | JetBrains PhpStorm Blog

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>