PhpStorm 2024.1 Help

Robo

PhpStorm lets you execute commands of the Robo PHP task runner right from the IDE.

If Robo is installed and initialized in your project, PhpStorm parses the contents of the RoboFile.php file, detects the public methods of the RoboFile class as executable commands, and displays them in a dedicated Robo tasks tool window. Alternatively, you can run the methods in the RoboFile.php file directly from the editor.

Robo overview in PhpStorm
Robo overview in PhpStorm

PhpStorm creates a default run configuration for the invoked Robo command, executes it and displays the output in the Run tool window.

Robo run tool window

Install and initialize Robo

To use Robo in PhpStorm, you need to install the Robo library in your project with Composer.

  1. Inside composer.json, add the consolidation/robo dependency record to the require or require-dev key. To get code completion for the package name and version, press Ctrl+Space.

    { "require-dev": { "consolidation/robo": "^4.0.3" } }
  2. Install the dependency to your project from composer.json by either of the following:

    • Click the Install shortcut link on top of the editor panel.

    • If the Non-installed Composer packages inspection is enabled, PhpStorm will highlight the declared dependencies that are not currently installed. Press Alt+Enter and select whether you want to install a specific dependency or all dependencies at once.

  3. In the Terminal tool window, execute the robo init command to add a RoboFile.php file to the project root.

    For guidance on adding commands to RoboFile.php, refer to the Robo documentation.

Run Robo tasks in PhpStorm

You can run a Robo command in PhpStorm by one of the following ways:

  • Double-clicking the command on the list in the Robo tasks tool window. To open the Robo tasks tool window, select the Robo tasks bar on the sidebar or select View | Tool Windows | Robo tasks from the main menu.

    Robo tasks tool window
    Robo tasks tool window
  • From the RoboFile.php file. Open RoboFile.php in the editor, click in the gutter next to the required method and select Run 'Robo task <name>' from the context menu.

  • As a Run Anything action. Press Ctrl twice to open the Run Anything popup and type the Robo command name in it.

    Run Robo with Run Anything

Manage Robo run configurations

As with any other run/debug configuration in PhpStorm, you can save as permanent, share, create from a template, group in folders, or save for later use a run configuration for Robo.

Create a custom Robo run configuration

You can create a custom Robo run configuration or edit an existing default one.

  1. Go to Run | Edit Configurations. Alternatively, select Edit Configurations from the list on the toolbar.

    Open the Edit Configurations dialog

    In the Edit Configurations dialog that opens, click the Add button (the Add button) on the toolbar and select Robo from the list.

    To edit the latest run configuration, click on the toolbar in the Run tool window.

  2. In the Robo configuration dialog that opens, fill out or edit the Robo-specific settings as follows:

    File

    Path to the robo executable file. PhpStorm by default sets the path to the robo file in the vendor/bin folder.

    Arguments

    The Robo command name and path to your RoboFile.php file where Robo methods with arguments are defined in the following format: <command name> --load-from <path to RoboFile.php>.

    Robo run configuration dialog

    For more information about configuring general run configuration settings, refer to Run/debug configurations dialog.

Run a Robo configuration as a startup task

  • If you have Robo tasks that you run on a regular basis, you can add the corresponding run configurations to a list of startup tasks in the Startup Tasks settings. The added tasks will be executed automatically on each project startup.

Last modified: 28 June 2024