Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

GimmeMylanta's avatar

Laravel Contracts vs PHP Interfaces

Hey guys, I was wondering if someone could help me out. Im currently learning about PHP Interfaces and im wondering what the difference between the Laravel Contracts and PHP Interfaces is? Also, where would be the best place to store interfaces and the classes that implement the interfaces in Laravel. Thanks Guys

0 likes
6 replies
zachleigh's avatar

Could you show an examole of the Laravel contracts you're talking about?

zachleigh's avatar

Laravel's Contracts are a set of interfaces

They are just Laravel specific interfaces.

GimmeMylanta's avatar

Ahhh ok, so they are the same thing.

Is there any best practice for storing my own contracts and implementations of these? ... I take it i should put them under the App directory, but where

zachleigh's avatar

They should be in the app directory, but as to where exactly you should put them, thats entirely up to you. I usually make folders for every service or component in a project and keep everything associated with the component, interface included, in that folder.

GimmeMylanta's avatar

@zachleigh Ok, so for instance, if i was backing up databases and using an interface to blueprint the methods, and then different files / classes for say MySQL, MSSQL etc, you would keep all the files associated with that in App/DatabaseBackup ?

Is that what your saying?

Please or to participate in this conversation.