Skip to end of metadata
Go to start of metadata

Redirection Notice



This tutorial describes setting up and running External Tools in PhpStorm.

While PhpStorm comes with a lot of integrated utilities and tools, it is virtually impossible to include every tool out there in the IDE. By configuring External Tools, we can create a shortcut to a tool which we can invoke from various menus or by using a keyboard shortcut.

Here's an example. Many image editors create PNG images that are not optimized. What if we wanted to run the OptiPNG tool to optimize our images and make it easy to run?

Let's see how to set this up!

1. Create an External Tool through the IDE Settings

From the settings (Ctrl+Alt+S or Cmd+, on Mac OS X), find IDE Settings | External Tools. We can use the green + to create a new External Tool.

In the window which opens, we can provide several basic options for the external tool:

  • Name - a name for the tool which will also be shown in menus.
  • Description - a description for the tool which will be shown in the PhpStorm status bar.
  • Group - a group for the external tools. When multiple external tools are created, it can be handy to group them into a submenu using this setting.

If we want to see the output of the external tool in a Console, we can keep the default Open console checkbox enabled. Optionally we can disable it and opt to only show the external tool output whenever an error occurs.

We can also specify where the tool is shown. I'm using the defaults here, where the External Tool will be visible from the Tools menu, the Editor menu and as a context menu in various Project views and Search results. Check the web help for a full explanation.

The most important settings will be the program to run, its arguments and its working directory. In the example above, OptiPNG will be run with the parameters -o4 $FilePath$. Note that we can make use of macros in these settings, which can be used to refer the project name, the current file path, a path to the PHP executable and so on. The Insert macro… button will list all available macros and their values.

2. (optional) Assign a keyboard shortcut to the External Tool

It can be useful to create a keyboard shortcut for the External Tool. From the settings (Ctrl+Alt+S or Cmd+, on Mac OS X), find the IDE Settings | Keymap and locate the tool we've just created in the tree. Use the Add Keyboard Shortcut context menu to assign a shortcut. In the example below, we are assigning the Alt+I shortcut:

3. Work with the External Tool

Once the tool is created, we can use it from the menus we specified. This can be the Tools menu, or a context menu in the Project view:

We can also make use of the keyboard shortcut assigned in Step 2: pressing Alt+I will run our external tool. Since we used the default settings in Step 1, a Console window will be opened in which the external tool's output is shown.

  • No labels