Skip to content
susi.dev
- Published on
- Authors

- Name
- Susanne Moog
When projects grow, a single services.yaml becomes unwieldy. Symfony’s DI supports imports so you can split configuration by domain (commands, listeners, repositories, …). This also works nicely in TYPO3 extensions.
Main services.yaml with imports
# Configuration/Services.yaml
services:
_defaults:
autowire: true
autoconfigure: true
public: false
# Import additional service definitions
imports:
- { resource: services/commands.yaml }
- { resource: services/listeners.yaml }
- { resource: services/repositories.yaml }
Example: commands.yaml
# Configuration/services/commands.yaml
services:
App\Command\CleanupCommand:
tags: ['console.command']
Example: listeners.yaml
# Configuration/services/listeners.yaml
services:
App\EventListener\MyListener:
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
Example: repositories.yaml
# Configuration/services/repositories.yaml
services:
App\Repository\CustomerRepository:
arguments:
$connection: '@doctrine.dbal.default_connection'
Tips
- Keep naming and folder structure consistent (one file per concern)
- Use
_defaultsin the main file to reduce boilerplate - In TYPO3, place files inside your extension (e.g.
EXT:my_ext/Configuration/...) and adjust paths accordingly
Conclusion
Using imports makes DI config easier to navigate and reduces merge conflicts in large teams.

Comments
Nothing yet. Say the first thing.
Sign in to join the conversation.