-
Notifications
You must be signed in to change notification settings - Fork 37
Imports
Mauro Gadaleta edited this page Jun 19, 2026
·
3 revisions
Split large service configuration files and compose them from a root config.
If your application ends up having many services, this file becomes huge and hard to maintain. To avoid this, you can split your service configuration into multiple service files:
For example:
# app/config/services/mailer.yml
services:
app.mailer:
class: ./App/Mailer
arguments: ['mail_transport']The definition itself hasn't changed, only its location. To make the service container load the definitions in this resource file, use the imports key in any already loaded resource
# app/config/services.yml
imports:
- { resource: services/mailer.yml }
- { resource: services/another.yml }{
"imports": [
{"resource": "services/mailer.json"},
{"resource": "services/another.json"}
]
}module.exports = {
imports: [
{resource: 'services/mailer.js'},
{resource: 'services/another.js'}
]
}<?xml version="1.0" encoding="UTF-8"?>
<container>
<imports>
<import resource="services/mailer.xml"/>
<import resource="services/another.xml"/>
</imports>
</container>Copyright © 2023-2024 Mauro Gadaleta