Skip to content

Imports

Mauro Gadaleta edited this page Feb 20, 2017 · 1 revision

Imports

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

YAML
# app/config/services.yml
imports:
    - { resource: services/mailer.yml }
    - { resource: services/another.yml }
JSON
{
  "imports": [
    {"resource": "services/mailer.json"},
    {"resource": "services/another.json"}
  ]
}
JS
module.exports = {
  imports: [
    {resource: 'services/mailer.js'},
    {resource: 'services/another.js'}
  ]
}