symfony: [Routing] "exclude" option ignored when "resource" doesn't end with "*?{["
Symfony version(s) affected: 4.4.*
Description
As described in Routing docs (v4.4), adding the exclude option should be possible when defining routes as annotations.
But, looking at https://github.com/symfony/config/blob/4.4/Loader/FileLoader.php#L81, it seems that exclude option is handled only when resource options ends with *?{[
To note:
- I encountered this (to be confirmed) bug during development, I didn’t run many tests
- code in branch FileLoader.php v5.* has changed, so I don’t know if the bug still exists in
5.*
How to reproduce
Very simple routes configuration:
# config/routes/annotations.yaml
app:
resource: '../../src/Controller/'
type: annotation
exclude: '../../src/Controller/ExcludedController.php'
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 22 (13 by maintainers)
Commits related to this issue
- Add note on nuances of the exclude config option As per reported issue https://github.com/symfony/symfony/issues/39588, currently the `exclude` option for attribute routing only works if the `resou... — committed to toby-griffiths/symfony-docs by toby-griffiths 2 years ago
- minor #20241 [Routing] Add note on nuances of the Routing exclude config option (toby-griffiths) This PR was submitted for the 7.1 branch but it was squashed and merged into the 6.4 branch instead. ... — committed to symfony/symfony-docs by javiereguiluz 2 years ago
for my case it worked to go with this glob:
Since version 6.2 there is a new default
routes.yaml. For exclusions to work, the following change was necessary for me:Just adding the glob pattern to
resource.pathdid not work for me, it produces the error “The file “…/src/Controller/**/*” does not exist”.Issue still persists in 7.0 and is quite confusing. Why is the
/src/Controller/**/*not the default?Hello? This issue is about to be closed if nobody replies.
I also just suffered from time lost to trying to work this by following the documentation for v7.1.
Could we at least update the docs to advise on this behaviour until we come up with a proper solution for this? I’ve raised https://github.com/symfony/symfony-docs/pull/20241 to address this.