6 months ago

Are the majority of the Laravel contracts/interfaces overkill?

Posted 6 months ago by booni3

Looking through a lot of the the Laravel 1st party code, I see a HUGE amount of contract/interface use. I understand the core concepts behind them:

  • Being able to switch out or use to different implementations. i.e. you may want have a payment processor contract that interfaces with both PayPal or Stripe. I see a real advantage of using contracts here.

  • Decoupling your code. Im not too sure what this one is about. The majority of people who are using Laravel are never going to want to switch out the core functionality for something else. i.e. you make a contract for a repository that is using Eloquent. I am sure there are very few people who would ever attempt to switch this out. What other use do contracts have here?

  • Readability - especially within something like Laravel's core code, I find this really useful to review all methods on a class.

So my question to you is:


  • You are not intended to switch out your framework, or any of the core components of it (i.e. Eloquent).
  • You are not writing code that anyone outside your team will need to view/work with.

What do you see the main benefits of writing interfaces, or would you agree they are generally overkill, and why does Laravel use them so so much?

Please sign in or create an account to participate in this conversation.