PhpStorm 2024.1 Help

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

Configure Symfony Command Line Tool 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 Symfony from the list, and specify its visibility level (Project or Global).

    the Command Line Tools dialog
  4. 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.

  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 Symfony 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 <s> <command> format.

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

    Running a symfony command

Terminate a command

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.

  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 Symfony command
  2. Create a run/debug configuration that will run the symfony 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 symfony executable file.

    • In the Arguments field, type the actual command and its arguments, such as app:list-users.

    Run/Debug Configurations dialog for Symfony 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 Symfony command
Last modified: 25 March 2024