Dependency injection Flashcards
1
Q
What are 2 ways to access services lazily from the DI-Container instead of using autowiring?
A
- service locator
- public service (not best practice)
2
Q
How can you make sure the DI-Container is configured in a valid way?
A
php bin/console lint:container
3
Q
How can you limit a service to be added to the container only in specific environments?
A
#[When(env: 'dev')] class SomeClass {