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).
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.
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.
Develop with pleasure!
– JetBrains PhpStorm Team