PhpStorm 2024.1 Help

Twig templates

Besides the common Symfony templates support, the Symfony Support plugin provides completion, navigation and code inspection specific to the Twig templating language.

Code completion in Twig templates

In the editor, press Ctrl+Space to invoke code completion for any of the following:

  • Provide Templates and Blocks for appropriate functions in any TWIG file.

    Name completion in Twig template
  • Provide Extensions, Filters and Macros, both self-defined or installed from a third party.

    Extension completion in Twig template
  • Provide individual assets and full bundles.

    Asset name completion in Twig template

Code navigation in Twig templates

To navigate to the declaration of a template, block, extension, filter, macro, or asset, place the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click the usage.

Navigate to Extension in Twig template

Code inspection in Twig templates

If we refer an asset that is not known to the application (for example, if the asset does not exist yet), PhpStorm displays the corresponding warning from the Missing Asset inspection.

Missing Twig Asset inspection
Last modified: 17 June 2024