Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages showcasing Symfony with Docker, APIs, queues & async tasks, Webpack, SPAs, etc.

WARNING: You are browsing the documentation for Symfony 3.1 which is not maintained anymore. Consider upgrading your projects to Symfony 5.2.

How to Visualize And Debug Routes

3.1 version

How to Visualize And Debug Routes

While adding and customizing routes, it’s helpful to be able to visualize and get detailed information about your routes. A great way to see every route in your application is via the debug:router console command. Execute the command by running the following from the root of your project.

$ php bin/console debug:router

This command will print a helpful list of all the configured routes in your application:

homepage              ANY       /
contact               GET       /contact
contact_process       POST      /contact
article_show          ANY       /articles/{_locale}/{year}/{title}.{_format}
blog                  ANY       /blog/{page}
blog_show             ANY       /blog/{slug}

You can also get very specific information on a single route by including the route name after the command:

$ php bin/console debug:router article_show

Likewise, if you want to test whether a URL matches a given route, you can use the router:match console command:

$ php bin/console router:match /blog/my-latest-post

This command will print which route the URL matches.

Route "blog_show" matches

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.