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

Enable the PHP Command Line Tool plugin

This functionality relies on the PHP Command Line Tool plugin, which is bundled and enabled in PhpStorm by default. If the relevant features aren't available, make sure that you didn't disable the plugin.

  1. Press Ctrl+Alt+S to open the IDE settings and then select Plugins.

  2. Open the Installed tab, find the PHP Command Line Tool plugin, and select the checkbox next to the plugin name.

Integrate an external PHP command line tool with PhpStorm

  1. Download and install the tool.

  2. In the Settings dialog (Ctrl+Alt+S) , go to Tools | PHP 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 PHP 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. For more information, refer to Customize a tool.

Run commands

Run a command

  • Go to 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 dialog (Ctrl+Alt+S) , go to Tools | PHP Command Line Tool Support.

  2. On the PHP Command Line Tools 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 (for more information, refer to Define your own command line tool). As you type, the tool descriptor is checked for well-formedness on the fly.

  4. Reload the command definitions. On the PHP Command Line Tools Support page of the Settings 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 dialog (Ctrl+Alt+S) , go to Tools | PHP 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 PHP Command Line Tools Support page, where the new tool is added to the list.

  4. Click OK to accept the changes and close the Settings 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 PHP Command Line Tools Support page of the Settings 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 dialog (Ctrl+Alt+S) , go to Tools | PHP 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. For more information, refer to Define your own command line tool.

Custom Tools Command Definitions

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

Last modified: 04 March 2024