PhpStorm 2020.2 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.

  4. In the Command Line Tools dialog, choose the tool from the list, and specify its visibility level (Project or Global).

    the Command Line Tools dialog
  5. When you click OK, the tool settings dialog opens. In this dialog, set up the tool execution.

  6. Click OK to apply changes and return to the Command Line Tool Support page. Optionally, click the Edit button to edit the tool properties, or the Edit Source button to customize the commands set. See Customize a tool for details.

Run commands

Run a command

  • From the main menu, choose Tools | Run Command or press Ctrl twice.

    In the Run Anything window that opens, type the call of the command in the <default alias> <command> format.

    The command execution result is displayed in the Run tool window.

    Running a composer command

Terminate a command

Customize 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 Define your own command line tool 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 of the Settings/Preferences dialog Ctrl+Alt+S, select the tool in the list and click the Reload command list from executable button on the toolbar.

Define your own command line tool

  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 and the tool alias.

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

  4. 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.

    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>
  5. Reload the command definitions. On the Command Line Tool Support page of the Settings/Preferences dialog Ctrl+Alt+S, select the tool in the list and click the Reload command list from executable button on the toolbar.

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

Keep a tool descriptor consistent

Every time you edit a command definition in the xml tool descriptor, PhpStorm checks it for well-formedness on the fly. Full validation is performed every time you invoke a command.

If any inconsistencies are detected, an error message in displayed in the Run tool window.

Verify the tool definition

  1. In the Settings/Preferences dialog Ctrl+Alt+S, go to Tools | Command Line Tool Support. The tools having an inconsistent descriptor are marked with the Warning icon.

    CLI tool validation error
  2. 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 as required. See Define your own command line tool for details.

Custom Tools Command Definitions

The following table lists several custom command line tools provided by third-party developers.

Last modified: 03 September 2020