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-routes.html in about 2 seconds.

 

Working with Routes

One of the cornerstones of developing a Symfony2 application is working with routes. The routing infrastructure ensures that we can use beautiful URLs (/products/hammer instead of index.php?page=products&productid=12345) and that these URLs are mapped to a controller in our application that can respond to requests. Let's check what the Symfony2 Plugin can do for us!

Completion and Navigation for Routes

Whenever we want to use a function that takes a route name, PhpStorm provides completion (Ctrl+Space). It will work for controller functions like generateUrl and forward, as well as for Twig functions like path or controller.



Since routes are linked to a controller, we can hover over the route name and press Ctrl+Click (or CMD+Click on Mac OS X) to navigate to it, or place the cursor on the route name and press Ctrl+B (or CMD+B on Mac OS X). From templates, we can navigate to the controller.

From the controller, we can navigate to the template or the route definition in routing.yml.

And to make the circle round, we can navigate back to our controller as well.

Missing Route Inspection

Whenever we use the name of a route that is not defined, the Symfony2 Plugin will warn us about this with its "Missing Route" Inspection. It will highlight the missing or misspelled route name in the editor.

 

  • No labels