-
Notifications
You must be signed in to change notification settings - Fork 34
LazyService
Mauro Gadaleta edited this page Mar 6, 2017
·
1 revision
In some cases, you may want to inject a service that is a bit heavy to instantiate, but is not always used inside your object. Configuring lazy services is one answer to this. With a lazy service the container builder will instantiate the service only when we need it (during the container get call method)
services:
app.mailer:
class: ./App/Mailer
lazy: true
{
"services": {
"app.mailer": {
"class": "./App/Mailer",
"lazy": true
}
}
}
let definition = new Definition(SomeClass)
definition.lazy = true
container.setDefinition('some_class', definition)
Copyright © 2023-2024 Mauro Gadaleta