Skip to content

[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 7.4
Choose a base branch
from

Conversation

santysisi
Copy link
Contributor

Q A
Branch? 7.4
Bug fix? no
New feature? yes
Deprecations? yes
Issues Fix #61344
License MIT

Summary

This PR enhances the Symfony\Component\Routing\Attribute\Route attribute by allowing the env parameter 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 dev and test environments, two separate route attributes were needed:

#[Route('/test', name: 'test', env: 'dev')]
#[Route('/test', name: 'test-testing', env: 'test')]

After

Now, the same can be achieved with a single attribute by passing an array:

#[Route('/test', name: 'test', env: ['dev', 'test'])]

@santysisi
Copy link
Contributor Author

I'm not entirely sure if this qualifies as a breaking change 🤔
If it is, I can update the UPGRADE.md and change the target branch from 7.4 to 8.0.

@santysisi
Copy link
Contributor Author

I believe the errors in this PR will be resolved by PR #61360 😄.

@santysisi santysisi force-pushed the feature/support-multiple-envs-in-route-attribute branch 3 times, most recently from bf489ae to a1ef1ee Compare August 8, 2025 22:10
@santysisi santysisi force-pushed the feature/support-multiple-envs-in-route-attribute branch 2 times, most recently from dbeae07 to 4b5d99d Compare August 9, 2025 13:30
@santysisi
Copy link
Contributor Author

I think the errors aren't relevant in the context of this PR

@santysisi santysisi force-pushed the feature/support-multiple-envs-in-route-attribute branch from 4b5d99d to 67d8e1e Compare August 10, 2025 20:08
@santysisi santysisi force-pushed the feature/support-multiple-envs-in-route-attribute branch from 67d8e1e to dcb540c Compare August 10, 2025 21:53
@santysisi
Copy link
Contributor Author

@GromNaN Thanks a lot for all your suggestions! I’ve made the changes ❤️

@santysisi santysisi force-pushed the feature/support-multiple-envs-in-route-attribute branch from dcb540c to 5fc6707 Compare August 11, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Routing] make it possible so that env parameter can set a array
3 participants