What is Laravel Contracts?

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.