Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Routing] allow setting multiple envs in#[Route] attribute#61358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Routing] allow setting multiple envs in#[Route] attribute#61358
Conversation
santysisi commentedAug 7, 2025
I'm not entirely sure if this qualifies as a breaking change 🤔 |
santysisi commentedAug 7, 2025
I believe the errors in this PR will be resolved byPR #61360 😄. |
Uh oh!
There was an error while loading.Please reload this page.
bf489ae toa1ef1eeCompareUh oh!
There was an error while loading.Please reload this page.
dbeae07 to4b5d99dComparesantysisi commentedAug 9, 2025
I think the errors aren't relevant in the context of this PR |
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RouteWithMultipleEnvs.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
4b5d99d to67d8e1eComparesrc/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RouteWithEnv.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/Routing/Tests/Fixtures/AttributeFixtures/RouteWithEnv.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
67d8e1e todcb540cComparesantysisi commentedAug 10, 2025
@GromNaN Thanks a lot for all your suggestions! I’ve made the changes ❤️ |
5fc6707 to2f6564aCompare| return$this->env[0]; | ||
| } | ||
| publicfunctionsetEnvs(array|string$env):void |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why do we have setters at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think adding the setter helps keep consistency with the current class design. But if you feel it’s unnecessary, I can remove it
just let me know 🫡
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
2f6564a to4dbbedeCompare4dbbede to2ad7ff3Comparesantysisi commentedAug 19, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks for the suggestions! 🙌 |
2ad7ff3 to525ec95Comparenicolas-grekas commentedAug 20, 2025
Thank you@santysisi. |
6726234 intosymfony:7.4Uh oh!
There was an error while loading.Please reload this page.
Summary
This PR enhances the
Symfony\Component\Routing\Attribute\Routeattribute by allowing theenvparameter to accept an array of environment names. This change enables defining a single route that is conditionally available in multiple environments without duplicating route definitions.Before
To make a route available in both
devandtestenvironments, two separate route attributes were needed:After
Now, the same can be achieved with a single attribute by passing an array: