IntelliJ IDEA 2019.2 Help

Using the WordPress Command Line Tool WP-CLI

To run WordPress in the command line mode, you will need a set of command line tools, which you can acquire by installing the wp-cli/wp-cli package using the Composer dependency manager or by downloading the wp-cli.phar archive. The downloaded command line tool must be registered in IntelliJ IDEA as described in PHP Command Line Tools.

For information about running the tool in the command line mode, see PHP Command Line Tools.

Before you start

  • Make sure the PHP interpreter is configured in IntelliJ IDEA on the PHP page, as described in Configuring Local PHP Interpreters and Configuring Remote PHP Interpreters.

  • Make sure the PHP and Command Line Tool Support plugins are installed and enabled.

    The plugins are not bundled with IntelliJ IDEA, but they can be installed from the JetBrains plugin repository as described in Managing plugins. Once enabled, the plugins are available at the IDE level, that is, you can use them in all your IntelliJ IDEA projects.
  • Configure the PHP interpreter to use WordPress with, as described Configuring Remote PHP Interpreters. Note that WordPress requires PHP 5.3 or later.

Installing the WP-CLI package using the Composer dependency manager

Before you start, make sure Composer is installed on your machine and initialized in the current project as described in Composer Dependency Manager.

Click Finish. The create-project Composer command will be invoked with the selected package. As a result, the Composer project will be created, whose configuration and structure depends on the selected package. After that, the created IntelliJ IDEA project opens.

  1. From the composer.json context menu, choose Composer | Manage Dependencies.

  2. In the Manage Composer Dependencies Dialog that opens, select the wp-cli/wp-cli package from the Available Packages list, possibly using the search field.

    Choose the relevant version from the Version to install list.

  3. If necessary, expand the Settings hidden area and specify the advanced installation options.

    In the Command line parameters field, type the additional command line parameters.

  4. Click Install.

Using WP-CLI as a IntelliJ IDEA command line tool

Before you begin, download the wp-cli.phar at WordPress CLI.

Configure WP-CLI as a 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.

  3. In the Command Line Tools dialog, choose WP-CLI from the list, and specify its visibility level (Project or Global).

    the Command Line Tools dialog
  4. When you click OK, the WP-CLI dialog opens.

    Choose the way to run WP-CLI:

    • Installed via PHAR: Choose this option to launch WordPress through a PHP script or have IntelliJ IDEA detect and start the launcher in the wp-cli.phar archive.

      Choose one of the configured local PHP interpreters from the PHP Interpreter list. See Configuring Local PHP Interpreters for details.

      In the Path to phar field, specify the location of the wp-cli.phar archive. Type the path manually or click the Browse button and choose the desired location in the dialog that opens.

    • Executable available (installed via Composer, and so on): choose this option to launch WordPress through an executable file, which is available when you install WordPress using a package management tool, for example, Composer.

      In the Path to wp.bat field, specify the location of the wp.bat or wp executable file. If you used Composer, the default location is \vendor\wp\cli\bin\wp or \vendor\wp\cli\bin\wp.bat. Type the path manually or click the Browse button and choose the desired location in the dialog that opens.

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

Run WP-CLI commands

You can run WP-CLI commands and analyze their output right in IntelliJ IDEA, just as the commands of any other command line tools, see PHP Command Line Tools.

  • 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 <wp> <command> format.

    The command execution result is displayed in the Run Tool Window.

Terminate a command

Last modified: 1 August 2019

See Also