How to view all defined routes in Symfony 2 PHP application

Every so often it is useful to list all of the defined routes in your Symfony application, whether to find out the name of the route, or to debug why a route is being used unexpectedly (routes are called based on the first one that matches). To view the routes, simply type the following in the console:

php app/console debug:router


php bin/console debug:router

depending on your version.


Create a simple CRUD app with Symfony2

Symfony2 has an in built command for building simple CRUD pages for your entities. You can use this to create simple admin pages very quickly.

The command is: php app/console generate:doctrine:crud

This will run in interactive mode giving you options on which entity to create the pages for and which pages to create (All the CRUD pages, or just the read pages).

The Configuration format option specifies (amoung other things) where the routing information is stored. I prefer to use yml so that all of my routing information is together.