Closed
Description
Symfony version(s) affected
6.4.1
Description
Route for controller B has priority set:
#[Route(path: '/b', name: 'b_method', priority: 9999)]
public function bMethodOne(): Response
When the prefix in routes.yaml
is commented out, the routing priority works as expected. The bin/console debug:router
command outputs the following:
❯ bin/console debug:router
---------------- -------- -------- ------ --------------------------
Name Method Scheme Host Path
---------------- -------- -------- ------ --------------------------
b_method ANY ANY ANY /b
_preview_error ANY ANY ANY /_error/{code}.{_format}
a_method ANY ANY ANY /a
---------------- -------- -------- ------ --------------------------
However, when the prefix is set, the routing priority seems to be lost. The bin/console debug:router
command then shows a different order:
controllers:
resource: '../src/**/*Controller.php'
type: attribute
prefix:
cs: ~
en: '/en'
❯ bin/console debug:router
---------------- -------- -------- ------ --------------------------
Name Method Scheme Host Path
---------------- -------- -------- ------ --------------------------
_preview_error ANY ANY ANY /_error/{code}.{_format}
a_method.cs ANY ANY ANY /a
a_method.en ANY ANY ANY /en/a
b_method.cs ANY ANY ANY /b
b_method.en ANY ANY ANY /en/b
---------------- -------- -------- ------ --------------------------
How to reproduce
https://github.com/SystematicCZ/Symfony-Routing-bug
Possible Solution
I will try to submit PR soon
Additional Context
No response