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: open
  • Created 4 years ago
  • Reactions: 5
  • Comments: 18 (12 by maintainers)

Most upvoted comments

for my case it worked to go with this glob:

controllers:
    resource: ../../src/Controller/**/*
    exclude: ../../src/Controller/Blog
    type: annotation

blog:
    resource: ../../src/Controller/Blog
    type: annotation
    name_prefix: blog_
    prefix: /blog/