What is dependency injection in a controller method?
Answer
Clear, interview-ready explanation
Dependency injection in a controller method means declaring a required service as a type-hinted argument and allowing Laravel’s service container to supply it. For example, a controller action can accept a ReportService $reports argument without manually constructing the service.
This keeps dependencies explicit, reduces coupling, and makes testing easier because the controller can depend on an interface and receive a fake implementation in a test. Laravel also injects framework services such as Request, and it can resolve other class dependencies automatically when their bindings are known.