Commit ad793ec
committed
minor symfony#21279 [Routing] correct environment-specific routing configuration examples (santysisi)
This PR was merged into the 6.4 branch.
Discussion
----------
[Routing] correct environment-specific routing configuration examples
### 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), <when env="dev"> 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
* [Allowed keys in YAML routing](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Routing/Loader/YamlFileLoader.php#L36-L38) — the env key is not permitted inside route definitions.
* [RoutingConfigurator::env() method](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Routing/Loader/Configurator/RoutingConfigurator.php#L63-L69) — this method returns the current environment and does not accept an environment name as an argument for filtering.
* [RouteConfigurator class](https://github.com/symfony/symfony/blob/6.4/src/Symfony/Component/Routing/Loader/Configurator/RouteConfigurator.php#L19) — does not have an env() method.
Commits
-------
5cac5ed [Routing] correct environment-specific routing configuration examples1 file changed
+12
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| |||
296 | 296 | | |
297 | 297 | | |
298 | 298 | | |
299 | | - | |
300 | | - | |
301 | | - | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
315 | 316 | | |
316 | 317 | | |
317 | 318 | | |
| |||
0 commit comments