Skip to end of metadata
Go to start of metadata

Redirection Notice

This page will redirect to in about 2 seconds.


Working with Templates

Many web applications consist of a number of pages, usually rendered on the server using a Twig or PHP-based template. Let's see how the Symfony2 Plugin helps us with this.


The Symfony2 Plugin also comes with a number of features specific to Twig. These are discussed further in this tutorial series.

Completion and Navigation for Templates

Remembering the exact syntax to refer to a template in a bundle is one thing; typing the entire thing is another. We can use basic completion (Ctrl+Space) whenever we want to make use of a template.

Next to completion for templates, we can use navigate to declaration to jump to a template. Simply hover over the template name and Ctrl+Click (or CMD+Click on Mac OS X) to navigate, or place the cursor on the template name and press Ctrl+B (or CMD+B on Mac OS X).


Completion and Navigation is available in PHP (controller or template) and Twig (template).

Creating a Template using a Quick-Fix

Often, our flow of coding is broken as we create a controller and want to render a template that is yet to be created. This would mean we have to jump to the Project Tool Window or the Navigation Bar and use the mouse or keyboard shortcuts to navigate to the correct directory and create a new template there.

The Symfony2 Plugin will do all of this for us! We type out the template name we want to use in our code. The IDE will detect it does not exist and highlight this. We press Alt+Enter to call up the Create Template quick-fix, which will create the template at the correct location in our project and bundle. It will also immediately open the template in a new editor tab so we can start working on it.


  • No labels