Skip to end of metadata
Go to start of metadata

Redirection Notice

Icon
This page will redirect to https://www.jetbrains.com/help/phpstorm/symfony-navigating-project.html in about 2 seconds.

 

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.

Using Navigate to Class, File or Symbol, we can use a keyboard shortcut to navigate to standard PHP, HTML, JavaScript or CSS types, or any file that is located in our project. We can use CamelHumps (searching for PI will yield PersonIterator and other classes matching the uppercase characters in the CamelCase naming) and wildcards to make searching even more convenient.

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:

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.

Icon

Wouldn't it be great to have a keyboard shortcut for this feature? Through the IDE Settings | Keymap, we can search for "Symfony2" and use the context menu to assign a keyboard shortcut to the "Symfony2 Symbol..." action.

We can now use Ctrl+, to navigate to Symfony2 Symbol.

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.

 

  • No labels