You can run commands, analyze and export their output right in IntelliJ IDEA using the Command Line Tools Console tool window. The character set to be used in the tool window is chosen from the Console encoding drop-down list on the Command Line Tool Support page of the Settings/Preferences dialog box.

Note that PHP-specific command line tools work only with local PHP interpreters.

Before you start, install and enable the PHP and Command Line Tool Support repository plugins on the Plugins page of the Settings / Preferences Dialog.

On this page:

Running a command

  1. On the main menu, choose Tools | Run Command. Depending on the Show console in setting in the Command Line Tool Support page, the Input pane opens either as a pop-up window or as a text box at the bottom of the Command Line Tools Console tool window.
  2. In the Input pane, type the call of the command in the format <tool alias> <command>.

    If you are using a tool from IntelliJ IDEA for the first time, create an initial tool project by running the tool-specific project generation command. The initial project is stored in the IntelliJ IDEA project root.

  3. View the result of command execution in the output tab named after the last invoked command.
  4. To terminate a command, click ../../Shared/stop.gif on the toolbar. If the Output tab is already closed, kill the current thread from the progress bar.

Most command line tools operate within the context of their native projects. Note that a tool project is not the same as a IntelliJ IDEA project.

Exporting the output

  1. Click ../../Shared/exportToTextFile.png on the toolbar or press ⌃O⌃O⌃O⌥ O⌥ O.
  2. In the Export Preview dialog that opens, do one of the following:
    • To save the output in a text file, specify the target text file in the Export to file text box and click Save. 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.
    • To copy the output to the clipboard, click Copy.

Running a command line tool automatically after committing changes

  1. Open the External Tools page (File | Settings | Tools | Command Line Tool Support for Windows and Linux or IntelliJ IDEA | Preferences | Tools | Command Line Tool Support for macOS).
  2. Configure the command line tool as an external tool.
  3. Start committing your changes.
  4. In the After Commit area of the Commit Changes Dialog, choose your tool from the Run tool list.