Navigating through a Project
Symfony2 comes with a number of concepts that are important for an application, including but not limited to: controllers (actions), routing, templating, the Doctrine ORM, testing, forms, translations, services, bundles, and configuration. Developing a Symfony2 application means integrating some (or all) of these together, often switching back and forth between different file and artifact types in our IDE.
PhpStorm and the Symfony2 Plugin come with ample options for navigating through a project.
Navigate to Class, File or Symbol
Here are some useful keyboard shortcuts:
- Navigate to Class: Ctrl+N (or CMD+O on Mac OS X)
- Navigate to File: Ctrl+Shift+N (or CMD+Shift+O for Mac OS X)
- Navigate to Symbol: Ctrl+Shift+Alt+N (or CMD+Alt+O for Mac OS X)
- Search Everywhere: Search Everywhere (Double Shift)
The Symfony2 Plugin extends this navigation functionality with (basic) support for bundles as well. By using Navigate to File (Ctrl+Shift+N (or CMD+Shift+O for Mac OS X)) we can easily search for Twig templates in a bundle:
Navigate to Symfony2 Symbol
The Symfony2 Plugin adds a new navigation option under the Navigate | Symfony2 Symbol menu. It allows us to navigate to any Symfony2 concept in our project: controllers, templates, routes, entities, and so on.
Navigate to Related
While working in a controller, the Symfony2 Plugin adds a new line marker in the left gutter of the editor that allows us to navigate to all related items that are available. If a controller renders a template, a Twig icon will be visible. If a route to the controller is found, a different icon will show. We can click this icon and navigate to the related file immediately.
Usually, multiple related items will be found. For example, most controllers will have a Twig template and a route related to them. The Symfony2 plugin will show a different icon and provide us with a pop-up window where we can pick the item to navigate to it.
Once we arrive at the related item, we can also navigate back to our controller.