PhpStorm 2019.1 Help

PHP Command Line Tools

PhpStorm supports running commands of popular third-party or user-defined PHP tools: Symfony 1.1+, Symfony2, Zend Framework 1, Zend Framework 2 (ZFTool), Yii, Composer, Drush 5.8+, Laravel and Doctrine (Symfony console-based), WordPress Command Line Interface.

Before you start, make sure the Command Line Tool Support plugin is enabled on the Plugins page of the Settings/Preferences dialog (Ctrl+Alt+S).

Integrate an external PHP command line tool with PhpStorm

  1. Download and install the tool.

  2. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Tools | Command Line Tool Support.

  3. Click the Add button on the toolbar.

    • In the Command Line Tools dialog, choose the type of the tool from the list.

    • In the Visibility area, specify whether you want to use the tool in the current project or globally, that is in any PhpStorm project.

  4. In the Alias field, accept the default alias to use in calls of tool commands or edit it if necessary.

  5. In the Show console in area, specify where you want to enter commands.

    • Popup: choose this option to have the Command Line Tools Input pane opened in a separate popup and type commands there.

    • Tool window: choose this option to enter commands in the Input field in the bottom of the dedicated Command Line Tools Console tool window.

  6. Optionally, customize the commands set as described in Customizing a tool.

Running commands

Run a command

  1. From the main menu, choose Tools | Run Command or press Ctrl+Shift+X. The Input pane opens as a popup or as a field at the bottom of the Command Line Tools Console tool window.

  2. Type the call of the command in the <tool alias> <command> format.

The command execution result is displayed in the Output tab with the command name.

Save the command output

  1. Click the Export to Text file button on the Output tab toolbar.

  2. In the Export Preview dialog that opens, specify the text file to store the output in or click Copy to save the output to clipboard.

    If the file with this name and location already exists, choose to overwrite its contents with the new data or to append the new data to the existing file.

Terminate a command

  • Click the Stop button on the toolbar. If the Output tab is already closed, kill the current thread from the progress bar.

Customizing a tool

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Tools | Command Line Tool Support.

  2. On the Command Line Tool Support page, select the tool in the list and click the Edit Source button on the toolbar. The xml tool descriptor opens in the editor.

  3. Update the definitions of the commands (see Defining tool commands for details). As you type, the tool descriptor is checked for well-formedness on the fly.

  4. Reload the command definitions. On the Command Line Tool Support page, select the tool in the list and click the Reload command list from executable button on the toolbar.

Defining your own command line tools

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Tools | Command Line Tool Support.

  2. Click the Add button on the toolbar and in the Command Line Tools dialog that opens, select Custom tool from the Choose tool list, and specify the visibility level for it (Project or Global).

  3. In the Tool Settings dialog, type the path to the tool, the tool alias, and provide a brief description of the tool.

    When you click OK, PhpStorm brings you to the Command Line Tool Support page, where the new tool is added to the list.

  4. In the Show console in area, specify where you want to enter commands.

    • Popup: choose this option to have the Command Line Tools Input pane opened in a separate popup and type commands there.

    • Tool window: choose this option to enter commands in the Input field in the bottom of the dedicated Command Line Tools Console tool window.

  5. Click OK to accept the changes and close the Settings/Preferences dialog.

    The tool definition xml file automatically opens in the editor, letting you define the tool commands. See Defining tool commands for details.

See Tutorial: integrating the Yii command line tool with PhpStorm for the step-by-step guide on integrating a custom command line tool.

Defining tool commands

A command's definition is organized as follows:

<command> < !--the command's container--> <name> !--the command itself, mandatory, and non-empty--> </name> <help> !--the command's help message, optional--> </help> <params> !--the command's parameters and their default values--> </params> <optionsBefore> < !--the command's options container--> <option name="" shortcut=""> !--the option itself, mandatory, and non-empty; you can also provide a shorthand abbreviation and the usage pattern via attributes--> <help> !--the command's help message, optional--> </help> </option> </optionsBefore> </command>

Keeping a tool descriptor consistent

Option 1: On-the-fly validation

Every time you edit a command definition in the xml tool descriptor, PhpStorm checks it for well-formedness on the fly.

Option 2: Full validation

Full validation is performed every time you invoke a command. If any inconsistencies are detected, the tool is marked with the Invalid description icon the Warning icon on the Command Line Tool Support page.

Run full validation

  1. Open the Input pane From the main menu, choose Tools | Run Command or press Ctrl+Shift+X. The Input pane opens as a popup or as a field at the bottom of the Command Line Tools Console tool window.

  2. To invoke validation, type the call of a command and in the Tool definition file errors tab, analyze the notifications on detected structure inconsistencies. Each notification shows a brief description of the problem, the file and the line number where the problem is detected.

    By default, the tab is hidden and opens when you click Show description in the Command Line Tool popup with an error notification. To close the tab, click the Close button the cross on its header. To re-open it, click More once again.

Last modified: 18 June 2019

See Also