PhpStorm 2024.1 Help

Use the Artisan command line tool from PhpStorm

PhpStorm integrates with the Artisan command line interface, which is included with Laravel and provides several handy commands.

Configure Artisan automatically

Configure Artisan manually

  1. In the Settings dialog (Ctrl+Alt+S) , go to Tools | PHP Command Line Tool Support.

  2. Click the Add button on the toolbar.

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

    the Command Line Tools dialog
  4. When you click OK, the tool settings dialog opens.

    Specify the tool alias, provide the path to artisan, and choose one of the configured PHP interpreters from the PHP Interpreter list. For more information, refer to Configure local PHP interpreters and Configure remote PHP interpreters.

    the artisan command-line tool settings
  5. 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 Artisan commands

  • Go to Tools | Run Command or press Ctrl twice.

    In the Run Anything window that opens, type the call of the command in the <artisan> <command> format.

    The command execution result is displayed in the Run tool window.

    Running a artisan command

Terminate a command

Debug Artisan commands

Laravel commands are defined in controller classes that extend Command. To debug a command, it is crucial that you initiate a debugging session for the command itself, and not the controller class file it is defined in. Otherwise, the Laravel bootstrapping process will be skipped, and the execution will fail.

  1. In the controller class corresponding to the selected command, click the editor gutter at a code line where you want to set a breakpoint.

    Set a breakpoint in a Laravel command
  2. Create a run/debug configuration that will run the artisan tool with the selected command. In the main menu, go to Run | Edit Configurations, then click the Add button and choose PHP Script from the list.

    Run/Debug configuration: PHP script
  3. In the PHP Script dialog, provide the run/debug configuration parameters.

    • In the File field, provide the path to the artisan executable file.

    • In the Arguments field, type the actual command and its arguments, such as view:cache.

    Run/Debug Configurations dialog for Laravel CLI command
  4. On the PhpStorm toolbar, select the created run/debug configuration and click the Debug button. The command execution will stop at the specified breakpoint.

    Debug a Laravel command
Last modified: 20 February 2024