Description
Q | A |
---|---|
Bug report? | no |
Feature request? | yes |
BC Break report? | no |
RFC? | yes |
Symfony version | 4.1 |
Often enough when defining a route, you want a certain condition bound to your parameter. Often those conditions are a digit, a set of alpha-numerical characters or maybe even a uuid. The gives a lot of repetition and chances of faulty conditions.
It would be nice if we could add some predefined conditions in the form of configuration via either the application or provide it via a bundle. The discussion on slack:
What could be good IMO could be to be able to set "default requirements" on routes. We have a lot of
"requirements"={"id"="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}"}
in our routes (uuids), so being able to have a kind of template / default "forid
, if not specified otherwise, use this requirement"
the ability to refer to predefined conditions would be nice
@Route("/foo/{bar<:uuid>}/")
using subroutines, we could make it
@Route("/foo/{bar<(?&uuid)>}/")
https://pcre.org/current/doc/html/pcre2syntax.html#SEC21
we would "just" need a way to define subroutines
please open an issue if you want to keep track of the idea
This in reference to the awesome feature that nicolas is working on: #26518