Answer the question
In order to leave comments, you need to log in
DIP principle from SOLID and Autowiring from DI containers?
The DIP principle states that dependencies should be on abstractions, not on a specific implementation.
For example this code:
public function __construct(LoggerInterface $logger) { }
Answer the question
In order to leave comments, you need to log in
Dependency injection is when we pass class B to class A through a constructor or setter so that it works with it, and does not create it in its own interiors.
Dependency Inversion is when we work in class A not with a specific implementation, but with interfaces: we specify interfaces in the constructor, in methods, in return types, etc.
These are two different concepts, which are sometimes combined into one, and sometimes they are confused.
So, autowiring is about Dependency injection, and D in solid is about Dependency Inversion. One does not interfere with the other and does not violate.
You have 2 options:
1. Trying to fix someone's mistakes.
2. Think with your head.
I chose - 2nd.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question