Features Releases

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

image description