Configuring Third-Party Tools
You can define third-party standalone applications (code generators and analyzers, pre- and post- processors, database utilities, etc.) as external tools and then run them from PhpStorm.
You can pass contextual information (like the currently selected file, or your project source path) to the external tools, view the tool output, and more.
The tools are defined on the External Tools page in the Settings dialog and appear as commands in the Tools menu and in various context menus. They can also be assigned keyboard shortcuts (see the Configuring Keyboards and Mouse Shortcuts section).
Tutorial: running an external tool in PhpStorm
Many image editors create non-optimized png images. To optimize images, you can use the OptiPNG command-line tool. Let's set it up for use in PhpStorm.
Create an External Tool
In the Settings/Preferences dialog (Ctrl+Alt+S), go to . Click to start creating a new External Tool.
In the Create/Edit/Copy Tool Dialog that opens, configure the tool by providing its options:
Name: a name for the tool, which will also be displayed in PhpStorm 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.
To see the output of the external tool in the Run Tool Window, keep the Open console checkbox selected. To only show the external tool output whenever an error occurs, clear the checkbox.
Provide the path to the program to run, its command-line arguments, and its working directory. In our case,
OptiPNGwill be run with the
-o4 $FilePath$arguments. You can make use of macros in these settings, which can refer to the project name, the current file path, a path to the PHP executable, and so on. Clicking the Insert macro button will open the Macros Dialog listing all available macros and their values.
Assign a keyboard shortcut to the External Tool
In the Settings/Preferences dialog (Ctrl+Alt+S), go to Keymap and locate the newly created Optimize PNG tool in the list.
Use the Add Keyboard Shortcut context menu action to assign a shortcut. In our case, we are assigning the N/A shortcut:
Work with the External Tool
Once the tool is created, you can run it from within PhpStorm. This can be the Tools menu, a context menu in the Project Tool Window view, or the assigned N/A keyboard shortcut.
When the tool runs, its output is displayed in the Run tool window: