Documentation

How to Inject or use Container as Service

How to Inject or use Container as Service

Inject the container itself when a service needs runtime access to other services.

You can use the container builder as reference if you need to use it around your application.

import {ContainerBuilder} 

const container = new ContainerBuilder(true)
...
const containerAsService = container.get('service_container')

Or you can use the configuration file.

YAML
services:
    app.some_manager:
        class: ./App/Service/SomeManager
        arguments: ['@service_container']

    # more services definition...