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
When you install Composer dependencies in a Laravel project, PhpStorm detects and configures Artisan automatically and displays a respective notification in the Composer Log.
If you want to customize the tool, click in the gutter to quickly jump to the PHP Command Line Tool Support settings page.
Configure Artisan manually
In the Settings dialog (Ctrl+Alt+S) , go to .
Click on the toolbar.
In the Command Line Tools dialog, choose Laravel from the list, and specify its visibility level (Project or Global).
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.
Click OK to apply changes and return to the PHP Command Line Tool Support page. Optionally, click to edit the tool properties, or to customize the commands set. For more information, refer to Customize a tool.
Run Artisan commands
Go to
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.
Terminate a command
Click on the Run tool window toolbar.
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.
In the controller class corresponding to the selected command, click the editor gutter at a code line where you want to set a breakpoint.
Create a run/debug configuration that will run the artisan tool with the selected command. In the main menu, go to , then click and choose PHP Script from the list.
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
.
On the PhpStorm toolbar, select the created run/debug configuration and click . The command execution will stop at the specified breakpoint.