services.yaml
imports:
- { resource: commands.yaml }
parameters:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
App\Service\ExampleService:
arguments:
- '%env(URL)%'
- '@doctrine.orm.entity_manager'
commands.yaml
parameters:
services:
App\Command\Import\ExampleCommand:
arguments:
- '@App\Service\ExampleService'
- '@monolog.logger.example'
- '@parameter_bag'
当我运行ExampleCommand
时,monolog实例默认为默认渠道。我认为ExampleCommand获得不同记录器的原因是自动装配。当我注释- { resource: commands.yaml }
时,命令运行没有错误。我有很多服务,需要分开配置。
一切正常,无需导入:
services.yaml
imports:
- { resource: commands.yaml }
parameters:
services:
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../src/*'
exclude: '../src/{Entity,Migrations,Tests}'
App\Controller\:
resource: '../src/Controller'
tags: ['controller.service_arguments']
App\Service\ExampleService:
arguments:
- '%env(URL)%'
- '@doctrine.orm.entity_manager'
App\Command\Import\ExampleCommand:
arguments:
- '@App\Service\ExampleService'
- '@monolog.logger.example'
- '@parameter_bag'
有很多进口的.yaml吗?