Assume following directory structure:
/src
/DTO
/Factory
/Collection
I want to exclude all classes, including classes from subdirectories of /DTO
directory
In my services file I do:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../src/*
exclude:
- '../src/DTO/*'
This leads to:
Symfony\Component\DependencyInjection\Exception\RuntimeException : Cannot autowire service App\DTO\Factory\Collection\MyCollection
If this service placed in DTO
folder directly - then autowiring works.
Can I specify the exclude expression in any way to include subfolders?
To exclude everything from DTO
folder use:
App\:
resource: '../src/*'
exclude:
- '../src/DTO'
ie w/o *
symbol
I found a solution to exclude not only classes placed directly in folder, but also subfolders with two asterisk signs ( **
).
Here is the example of a valid configuration:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../src/*
exclude:
- '../src/DTO/**'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.