Skip to content

[Routing] correct environment-specific routing configuration examples #21279

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

Merged
merged 1 commit into from
Aug 11, 2025

Conversation

santysisi
Copy link
Contributor

@santysisi santysisi commented Aug 7, 2025

Description

This PR updates the Symfony routing documentation examples to reflect the correct way to define environment-specific routes using when@dev (YAML), <when env="dev"> (XML), and conditional logic in PHP.

Changes Made

  • YAML: Replaced env: dev with when@dev syntax block.
  • XML: Wrapped the <route> element in a <when env="dev"> element.
  • PHP: Added conditional logic using $routes->env() to only register the route in the dev environment.

Why?

The previous examples used either unsupported keys or incorrect syntax for defining environment-specific routes (e.g. using env: dev directly inside a route definition). This update replaces those with the correct environment-based separation using when@dev blocks (YAML), wrappers (XML), and runtime conditionals in PHP. It ensures that environment-specific routes are properly scoped and configured according to Symfony's routing system.

References

@javiereguiluz
Copy link
Member

I wasn't aware that this routing config was so wrong! Santiago, thanks a lot for fixing it.

@javiereguiluz javiereguiluz merged commit ad793ec into symfony:6.4 Aug 11, 2025
3 checks passed
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.

4 participants