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] Simplify importing routes defined on controller services#62302

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
fabpot merged 1 commit intosymfony:7.4fromnicolas-grekas:route-tagged
Nov 5, 2025

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedNov 4, 2025
edited
Loading

QA
Branch?7.4
Bug fix?no
New feature?no
Deprecations?no
Issues-
LicenseMIT

Fine-tuning#61492

Before:

controllers:resource:attributestype:tagged_services

After:

controllers:resource:routing.controllers

And when usingMicroKernelTrait (the default recipe), there's nothing to configure to have routes loaded from#[Route] attributes:

#config/routes.yaml# the file can be just empty from any config, and only have a comment saying what it's for
// config/routes.phpreturn Routes::config([]);

The way to opt-out from thisrouting.controllers import would be to override theKernel::configureRoutes() method.

Kocal, javiereguiluz, and yceruto reacted with rocket emoji
if ($fileName = (new \ReflectionObject($this))->getFileName()) {
$routes->import($fileName,'attribute');
}
$routes->import('routing.controllers');
Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasNov 4, 2025
edited
Loading

Choose a reason for hiding this comment

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

the kernel being autoconfigured, it'll get therouting.controller tag once it uses a#[Route] attribute

@nicolas-grekasnicolas-grekas added the ❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze" labelNov 4, 2025
if ($fileName = (new \ReflectionObject($this))->getFileName()) {
$routes->import($fileName,'attribute');
}
$routes->import('routing.controllers');
Copy link
Member

Choose a reason for hiding this comment

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

this makes any route defined on a class with therouting.controller tag win over routes defined inroutes.yaml, while the existing solution respects the order of route definitions and so the current import might not be last. This could be a BC break if a project relies on such override.

And it also makes it impossible to override a route definition coming from a third-party bundle if that bundle defines a service tagged withrouting.controller. This second issue could be solved by importing thosebefore theroutes.yaml (orroutes.php) file though (but still after theroutes/*.yaml files where recipes are importing third-party routes)

Copy link
MemberAuthor

@nicolas-grekasnicolas-grekasNov 4, 2025
edited
Loading

Choose a reason for hiding this comment

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

I moved the import betweenroutes/* androutes.yaml
Doesn't that solve everything?

@yceruto
Copy link
Member

yceruto commentedNov 4, 2025
edited
Loading

Nice!

config/routes.yaml
the file can be just empty from any config, and only have a comment saying what it's for

I'd even vote for removing it from the recipe

@javiereguiluz
Copy link
Member

I'd even vote for removing it from the recipe

I'd keep it for now because it's not that rare to have to add some manual config in this file.

yceruto and nicolas-grekas reacted with thumbs up emoji

Copy link
Member

@fabpotfabpot left a comment

Choose a reason for hiding this comment

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

Nice!

@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commitf656af9 intosymfony:7.4Nov 5, 2025
11 of 12 checks passed
@nicolas-grekasnicolas-grekas deleted the route-tagged branchNovember 5, 2025 12:38
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@fabpotfabpotfabpot approved these changes

@javiereguiluzjaviereguiluzjaviereguiluz approved these changes

@ycerutoycerutoyceruto approved these changes

@alexandre-dauboisalexandre-dauboisalexandre-daubois approved these changes

Assignees

No one assigned

Labels

Routing❄️ Feature FreezeImportant Pull Requests to finish before the next Symfony "feature freeze"Status: Reviewed

Projects

None yet

Milestone

7.4

Development

Successfully merging this pull request may close these issues.

7 participants

@nicolas-grekas@yceruto@javiereguiluz@fabpot@stof@alexandre-daubois@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp