What is Laravel Contracts?
Why Interviewers Ask This
Advanced questions like this reveal whether a candidate has internalized Laravel deeply enough to make architectural decisions. Strong answers demonstrate both breadth and depth of experience.
Answer
Laravel Contracts are a set of interfaces that define the core services provided by the framework, located in Illuminate\Contracts. They define the "public API" of each service: Illuminate\Contracts\Cache\Repository, Illuminate\Contracts\Queue\Queue, Illuminate\Contracts\Mail\Mailer, Illuminate\Contracts\Auth\Guard. Type-hinting against Contracts rather than concrete classes makes code more loosely coupled and easier to test — swap the entire cache implementation by rebinding the contract in the container. Contracts differ from Facades: Facades provide a static API to concrete classes, while Contracts define an interface that can have multiple implementations. All Facades implement a corresponding Contract. Always prefer Contract type-hints in package development.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Laravel answers easy to follow.