Warm tip: This article is reproduced from serverfault.com, please click

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

发布于 2015-12-03 17:07:27

As far as I can tell, Laravel refers to the interfaces it extends as Contracts because they are used by Laravel. But this seems a bit like circular reasoning. There is no value added in changing the terminology of an existing PHP feature simply because your project uses it.

Is there something more to it? What's the logic behind coining a new term for something that's a standard PHP feature? Or is there some feature of Contracts that are not already in Interfaces?

Edit: To clarify, it's the usage of Contract as a proper noun in the documentation that has me confused, as explained in my comment on Thomas's post

Questioner
Brynn Bateman
Viewed
0
Gennady Basov 2015-12-04 01:42:15

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