What's the difference between a Contract in Laravel and an Interface in PHP?

"Contract" isn't some new terminology that Taylor coined. It's a very common term programmers use.

An interface is a contract, but a contract doesn't necessarily have to be an interface. The interface in a nutshell defines the contract that the classes must implement.

An abstract class is also a contract. The difference is that an abstract class can provide actual implementations, state, etc., and as a result, it is (in a sense) a more rigorous contract.

Another key difference is that a child class can only extend 1 abstract class but it can implement multiple interfaces.

So basically, "contract" isn't a new naming convention. It's a common term that Taylor is using.


It's just a nice word to describe the idea of using interfaces.

Laravel contracts are just PHP interfaces so they don't provide any other functionality.

You can read more on this subject in the documentation http://laravel.com/docs/5.1/contracts


As others have said, that is just a fancy word for Interfaces, but I think that Taylor made that decision to make it more personal.

What I mean by personal is that interface it's a very broad/common word on programming language, you have your interfaces, libraries (that you might be using) have their own interfaces and so on.

Contracts you just assume as the Laravel interfaces it's like a wrapper or alias for all the Interfaces that belong to this repo.