New in Symfony 4.3: Routing improvements
March 14, 2019 • Published by Javier Eguiluz
Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.
Boolean Container Parameters in Routes
Contributed by
David Maicher
in #30379.
In Symfony apps, it's possible to use container parameters in the routes config. In Symfony 4.3 we improved this feature to also support boolean parameters, so you can do things like this:
1 2 3 4 5 6 7
/**
* @Route("/test", condition="%kernel.debug%")
*/
class TestController extends AbstractController
{
// ...
}
Deprecated Some Router Options
Contributed by
Tobias Schultze
in #30249.
The following Routing component config options have been deprecated and they will be removed in Symfony 5.0:
generator_base_class
generator_cache_class
matcher_base_class
matcher_cache_class
These classes are no longer used after some recent changes in the Routing code. Besides, using parameters to define the class to use is a practice that Symfony discouraged a few years ago.
Displayed the Route Conditions When Debugging
Contributed by
Soufian Ez-Zantar
in #29254.
The debug:router
command helps you debug routing issues by listing all the
available routes and displaying all the details for a given route. In Symfony
4.3 we improved this command to also display the condition of the route (if
defined):
1 2 3 4 5 6 7 8 9 10 11 12 13
$ php bin/console debug:router some_route_name
+--------------+-------------------------------------------------------------------+
| Property | Value |
+--------------+-------------------------------------------------------------------+
| Route Name | |
| Path | /name/add |
| Host | localhost |
| Scheme | http|https |
| Method | PUT|POST |
| ... |
| Condition | context.getMethod() in ['GET', 'HEAD', 'POST'] |
+--------------+-------------------------------------------------------------------+
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
Using boolean container parameter in route config makes life easier :D
Thanks!!