IntelliJ IDEA 2020.1 Help

PHP command line tools

IntelliJ IDEA 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, install and enable the PHP and Command Line Tool Support repository plugins on the Plugins page of the Settings/Preferences dialog Ctrl+Alt+S.

Integrate an external PHP command line tool with IntelliJ IDEA

  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 Customizing a tool for details.

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

Terminate a command

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 your own command line tools 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.

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

    When you click OK, IntelliJ IDEA 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.

Keeping a tool descriptor consistent

Every time you edit a command definition in the xml tool descriptor, IntelliJ IDEA 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 (see Defining your own command line tools for details) as required.

Custom Tools Command Definitions

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

Last modified: 15 April 2020