NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Senior1 view

What dependency injection methods are available in Laravel?

Practice

Asked at

AI answer

The primary approach is constructor injection: Laravel automatically resolves dependencies registered with, or automatically created by, the container. Dependencies can also be injected into controller methods, regular methods, commands and handlers, as well as route handlers. The container is configured using bindings (bind, singleton, scoped), interfaces, and contextual bindings. Facades provide access to services, but they are not usually considered dependency injection: they are a static interface to the container.