IntelliJ IDEA 2022.2 Help

Symfony Templates

Web applications commonly comprise a number of pages usually rendered on the server using Twig or PHP-based templates.

Install the required plugins

This functionality relies on the PHP, Symfony Support, and PHP Annotations plugins that should be installed and enabled in your IDE.

The plugins are available only in IntelliJ IDEA Ultimate.

  1. Press Ctrl+Alt+S to open the IDE settings and select Plugins.

  2. Switch to the Marketplace tab and use the search field to find the plugins.

  3. Click Install next to each plugin and restart the IDE if prompted.

Code completion for templates

The Symfony Plugin enables context-aware completion Ctrl+Space for template names:

Symfony template name completion

Code navigation for templates

To navigate to the declaration of a template, position the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click the usage.

Navigating to Symfony template declaration

Creating a Template by using a Quick-Fix

Situations in which you refer to a template that is yet to be created are quite common. Instead of switching to the Project tool window or the Navigation Bar and using the mouse or keyboard shortcuts to navigate to the correct directory and create a new template, use the Create Template quick-fix provided by the Symfony Plugin. This will create the template at the correct location in your project and bundle and immediately open the template in a new editor tab.

Creating a Symfony template via intention action
Last modified: 29 November 2022