Using the Symfony command line tool from PhpStorm
PhpStorm integrates with the Symfony Console component and scripting interface. Before you begin, install Symfony Console as described in the Symfony documentation.
Configure Symfony Command Line Tool automatically
When you install Composer dependencies in a Symfony project, PhpStorm detects and configures Symfony Console 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 Symfony Command Line Tool manually
In the Settings dialog (Ctrl+Alt+S) , go to .
Click on the toolbar.
In the Command Line Tools dialog, choose Symfony from the list, and specify its visibility level (Project or Global).
When you click OK, the Symfony dialog opens.
Provide the path to the Symfony console executable file and the PHP interpreter, set the Symfony version, and click OK.
The default executable location is <Symfony-home>/data/bin/symfony for Symfony 1.*, <Symfony-home>/app/console for Symfony 2, and <Symfony-home>/bin/console for Symfony 3 and later.
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 Symfony commands
Go to
or press Ctrl twice.In the Run Anything window that opens, type the call of the command in the
<s> <command>
format.The command execution result is displayed in the Run tool window.
Terminate a command
Click on the Run tool window toolbar.
Debug Symfony commands
Symfony 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 Symfony 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 symfony 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 symfony executable file.
In the Arguments field, type the actual command and its arguments, such as
app:list-users
.
On the PhpStorm toolbar, select the created run/debug configuration and click . The command execution will stop at the specified breakpoint.