I’m am trying to organize my controllers a bit more in a Symfony 5.3 application. They are in a couple of subdirectories and use annotations for their routing. Here are some samples:
- ../src/StuffA/Controller/ControllerA.php
- ../src/StuffB/Controller/ControllerB.php
I now want to specify both inside my annotations.yaml
. I tried several approaches, but could not find anything that works:
Wildcards – Does not work
controllers: resource: '../../src/*/Controller' type: annotation
Multiple Paths – Does not work
controllers: resource: '../../src/{StuffA,StuffB}/Controller' type: annotation
Single Paths – Works but only for one Controller
controllers: resource: '../../src/StuffA/Controller' type: annotation
Any hint on what I’m doing wrong?
Advertisement
Answer
Just create multiple resource keys.
E.g.:
# annotations.yaml controllersFoo: resource: ../../src/Foo/Controller/ type: annotation controllersBar: resource: ../../src/Bar/Controller/ type: annotation
I don’t think you can use wildcards or glob patterns with the annotation loader.