Symfony News

New in Symfony 4.3: Routing improvements

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']                    |
+--------------+-------------------------------------------------------------------+

Be trained by Symfony experts - 2019-03-18 Cologne - 2019-03-18 Cologne - 2019-03-18 Clichy


About us

What a Symfony developer should know about the framework: News, Jobs, Tweets, Events, Videos,...

Find us on Twitter

Find us on Facebook

ADS