Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Routing] Clarify route aliases examples with explicit route names#20688

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

Merged
OskarStark merged 1 commit intosymfony:6.4fromwelcoMattic:route-alias-examples
May 20, 2025

Conversation

welcoMattic
Copy link
Member

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

Vitexus reacted with thumbs up emoji
@welcoMatticwelcoMattic changed the title[Routing] fix(route-alias): Clarify route aliases examples with explicit route names[Routing] Clarify route aliases examples with explicit route namesFeb 25, 2025
@carsonbotcarsonbot added this to the6.4 milestoneFeb 25, 2025
@welcoMattic
Copy link
MemberAuthor

@javiereguiluz this one could be merged to unlock#20638

@javiereguiluz
Copy link
Member

I'm not sure about these changes. I think the previous description (old route + new route) was more clear.

The new names (some route + alias to some route) could be less clear, especially the new route name. Including "alias" as part of the route alias is unnecessarily long in my opinion and could make some readers think that the route alias must contain thatalias prefix.

Let me ask@xabbuh and@OskarStark about this. Thanks!

@welcoMattic
Copy link
MemberAuthor

I'm not sure about these changes. I think the previous description (old route + new route) was more clear.

The new names (some route + alias to some route) could be less clear, especially the new route name. Including "alias" as part of the route alias is unnecessarily long in my opinion and could make some readers think that the route alias must contain thatalias prefix.

Let me ask@xabbuh and@OskarStark about this. Thanks!

I can replace "alias" with "new", but it implies underlying use case: replacing thesome_route usage with the alias. In my mind aliases are not necessarily here to replace existing routes, but to co-exists.
Imagine 2 websites sharing the same codebase except templates, 1 for BrandA and another for BrandB. Route aliases can be used to name route according to the Brand name in dedicated templates.

We can add a site note to mention the alias name is not mandatory to contain "alias" word.

These changes are on purpose to clarify the behavior using the Attribute way to alias route.

@stof
Copy link
Member

stof commentedFeb 26, 2025
edited
Loading

If you want to replace, you will generaly define the route with the new name and add a BC alias for the old name (especially when you want to deprecate it). That was the main confusion with the existing example.new_route_name is the deprecated name.

damienfern and welcoMattic reacted with thumbs up emoji

@welcoMattic
Copy link
MemberAuthor

welcoMattic commentedMar 4, 2025
edited
Loading

I think we do not have to presume what users will do with route aliasing feature (e.g creating new route and create an alias with the old route name). Just showing how to generally use route aliasing with generic terms, and then users will adapt to their needs/preferences. WDYT?

EDIT: I've update the PR by adding a small paragaph to explain clearly how route aliasing can be used to provide BC for renamed routes.

cc@javiereguiluz

@javiereguiluz
Copy link
Member

Maybe it's me, but this looks very confusing:

You create an alias ... and immediately deprecate it. The alias, being a new thing that you add, feels like the new route name, not the legacy route name.


I still think we should use names like "new_route_name" and "original_route_name" or "legacy_route_name". It's true that this alias feature can be used in different ways, but I think we should focus on its main usage and use terms that are impossible to misunderstand.

@damienfern
Copy link
Contributor

damienfern commentedMar 12, 2025
edited by OskarStark
Loading

I understand@javiereguiluz POV because I had the same feeling about aliases. Isn't this a sign that aliases on routes are plugged in a wrong way ?

IMHO, here is how it should be (a first draft, I don't know if it's doable):

some_route_name:path:/some-pathcontroller:App\Controller\SomeController::indexalias:alias_to_some_route_name:# this outputs the following generic deprecation message:# Since acme/package 1.2: The "alias_to_some_route_name" route alias is deprecated. You should stop using it, as it will be removed in the future.deprecated:package:'acme/package'version:'1.2'

@Jean-Beru
Copy link
Contributor

Jean-Beru commentedApr 7, 2025
edited by OskarStark
Loading

IMO, theblog post explains clearly the concept of deprecating a route. We could update the documentation in that way. eg:

My current route.

some_route_name:path:/some-pathcontroller:App\Controller\SomeController::index

I want to deprecate it in favor ofnew_route_name.

some_route_name:alias:new_route_name# this outputs the following generic deprecation message:# Since acme/package 1.2: The "some_route_name" route alias is deprecated. You should stop using it, as it will be removed in the future.deprecated:package:'acme/package'version:'1.2'new_route_name:path:/some-pathcontroller:App\Controller\SomeController::index
welcoMattic reacted with thumbs up emoji

@welcoMattic
Copy link
MemberAuthor

I've addressed comments, now examples are more explicit and I hope clearer:

First code block with initial route definition

# config/routes.yamlsome_route_name:path:/some-pathcontroller:App\Controller\SomeController::index

Second code block with an alias to the initial route

# config/routes.yamlsome_route_name:path:/some-pathcontroller:App\Controller\SomeController::indexnew_route_name:# "alias" option refers to the name of the route declared abovealias:some_route_name

Third code block where we "invert" the alias to be able to deprecate the initial route

# Move the concrete route definition under ``new_route_name``new_route_name:path:/some-pathcontroller:App\Controller\SomeController::index# Define the alias and the deprecation under the ``some_route_name`` definitionsome_route_name:alias:new_route_name# this outputs the following generic deprecation message:# Since acme/package 1.2: The "some_route_name" route alias is deprecated. You should stop using it, as it will be removed in the future.deprecated:package:'acme/package'version:'1.2'# or# you can also define a custom deprecation message (%alias_id% placeholder is available)deprecated:package:'acme/package'version:'1.2'message:'The "%alias_id%" route alias is deprecated. Do not use it anymore.'

I've also rephrased text paragraphs before and after each code block to explicitly explain what is the goal in each code block.

@javiereguiluz@Jean-Beru@damienfern@stof let me know if this version is good to you 🙏

@OskarStark
Copy link
Contributor

Can we use something likeproduct_show as old andproduct_detail as aliased route to add more real world feeling?

@welcoMattic
Copy link
MemberAuthor

@OskarStark thanks for you review. I've fixed minor comments and renamed example routes.

I think we hit the most clear version we can:

  • Real life route names
  • Not confusing naming
  • Clear explaination of each code block
  • Common thread between Route Alias and Route Deprecation features

@OskarStarkOskarStark requested a review fromxabbuhMay 6, 2025 09:06
@OskarStarkOskarStark requested review fromjaviereguiluz and removed request forstofMay 6, 2025 09:06
@welcoMattic
Copy link
MemberAuthor

Merging this one will unlock#20638 and allow me to finish Route Alias documentation refreshing 🙏

@OskarStark
Copy link
Contributor

@symfony/docs can we get another approval please? Thanks

Copy link
Member

@javiereguiluzjaviereguiluz left a comment

Choose a reason for hiding this comment

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

The new docs are now super clear to me! Thanks a lot Mathieu for the patience during the review process.

welcoMattic reacted with heart emoji
routing.rst Outdated
Route alias allow you to have multiple name for the same route:
Route alias allows you to have multiple name for the same route
and can be used to provide backward compatibility for routes that
have been renamed.
Copy link
Member

Choose a reason for hiding this comment

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

should we mention that this BC is only for route generation ? If you inspect the_route request attribute after url matching, the canonical name of the route will always be used here, not the name of an alias.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

👍 for me.

I think we could focus on this after complete update of Route Alias (including#20638)?

We could address this topic individually on Route Alias and Deprecation paragraphs to indicate in each case what will be the value of_route requrest attribute.

The current PR is more about clarification of the existing documentation.

@welcoMattic
Copy link
MemberAuthor

@symfony/docs comments addressed, ready to be merged 🎉

@OskarStark
Copy link
Contributor

Thank you Mathieu.

welcoMattic reacted with heart emoji

@OskarStarkOskarStark merged commit6556d97 intosymfony:6.4May 20, 2025
3 checks passed
@welcoMatticwelcoMattic deleted the route-alias-examples branchMay 20, 2025 15:12
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@stofstofstof approved these changes

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

@OskarStarkOskarStarkOskarStark approved these changes

@Jean-BeruJean-BeruJean-Beru approved these changes

@damienferndamienferndamienfern approved these changes

@dfernandes-wanadevdfernandes-wanadevdfernandes-wanadev approved these changes

@xabbuhxabbuhAwaiting requested review from xabbuh

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

9 participants
@welcoMattic@javiereguiluz@stof@damienfern@Jean-Beru@OskarStark@xabbuh@dfernandes-wanadev@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp