Adding external tools to phpStorm

In this guide I will show you how to add custom commands into phpStorm such as php-cs-fixer or any tools you may want to dynamically run in your project. There is built in documentation on this, but it is often handy to show examples of a specific use case.

In this example I will show adding 2 options for the tool php-cs-fixer, one which will work on an individual file, and one which will work on a given directory.

These settings do appear to be project specific, to start lets go to: File > Settings

From here under IDE settings there’s an option called External Tools

The following screenshot shows the settings I have used for one of my External Tools, it uses a macro to pick up the files folder, and filename to pass this into my command (in this case the php-cs-fixer).

The working directory I set to my project folder and the group is the first level on the context menu, so after I save and apply these changes I now have an extra options on my context menu (right click).

Here’s the end result.

Running these has the same effect as running the command in the terminal but is a handy right click option from my IDE – saves having to continuously switch windows and disrupt workflow.

I hope you found this useful, and shameless plug if you did please subscribe.