How does DIP relate to dependency injection?

Answer

DIP is the principle; Dependency Injection is the pattern that implements it. DIP states that high-level modules should depend on abstractions, not concretions. Dependency Injection is the mechanism that makes this possible: instead of a class creating its own dependencies (new ConcreteService()), they are provided (injected) from outside. Without DI, achieving DIP requires manually passing dependencies through constructors or factory methods. DI containers automate this by maintaining a registry of interface-to-implementation mappings and resolving the full dependency graph automatically. Laravel's service container, for example, automatically injects a concrete EmailService wherever an EmailInterface is type-hinted, fully implementing DIP with minimal boilerplate.