Skip to content

[Routing] Add Attribute code examples for alias in #[Route] attribute #20638

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 2 commits into
base: 7.3
Choose a base branch
from

Conversation

welcoMattic
Copy link
Member

Fixes #20600

This one adds code examples to alias route in #[Route] attribute. It also add example using DeprecatedAlias.

I've also added a note to precise new_route_name and original_route_name meaning, to avoid misunderstanding.

cc @damienfern

@welcoMattic
Copy link
Member Author

@stof for review

I've fixed issues we talk about in private.

But, as we discussed, we need to make this Route Alias part of the documentation a bit clearer on lower branches. This PR documents the new way to create route aliases using Attributes (which differs from the way to do in YAML, XML and PHP, if I've understood correctly).

OskarStark added a commit that referenced this pull request May 20, 2025
… route names (welcoMattic)

This PR was squashed before being merged into the 6.4 branch.

Discussion
----------

[Routing] Clarify route aliases examples with explicit route names

Refers to #20638 (comment)

Actual examples for route aliasing are not crystal clear.

Now, examples in YAML, XML and PHP provide

- An original route, declared with an explicit name
- An alias to this route, with an explicit name

This change will allow to provide another clear example for route aliasing using Attribute in #20638

cc `@stof` `@damienfern`

Commits
-------

a28b614 [Routing] Clarify route aliases examples with explicit route names
@welcoMattic welcoMattic force-pushed the alias-route-attribute branch from d65f27b to 848f249 Compare May 20, 2025 13:15
@welcoMattic
Copy link
Member Author

welcoMattic commented May 20, 2025

@symfony/docs I reworked this PR to only add PHP Attribute code blocks about Route Aliasing and Deprecated Route Aliases. Your review is welcome 🙏

Status: Needs review

@OskarStark OskarStark changed the title [Routing] Add Attribute code examples for alias in #[Route] attribute [Routing] Add Attribute code examples for alias in #[Route] attribute May 20, 2025

So that you can use your own route name for URL generation,
while actually using a route defined by a third-party bundle as the target of that URL generation,
as the 2 definitions are not required to be in the same config file (or even in the same format).
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OskarStark @stof I've added this side note, is it ok for you?

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] Allow aliases in #[Route] attribute
6 participants