DEV Community

Yogesh Galav
Yogesh Galav

Posted on

Repository vs Service Pattern

Hello Developers!!

There's a long outstanding debate between Repository Pattern and Service Pattern. What should we use and where?
Take a look at below given idea, Nobody is being talking about it but ever since I implemented it in enterprise grade application, the things become easy to implement especially in Laravel.

Repository Pattern

  • Business logic
  • Database queries
  • Model abstraction
  • Keeps controllers thin
  • No inheritance, just direct static method calls

Service Pattern

  • Third-party integrations
  • SMS, Email, Payment gateway
  • External APIs
  • Infrastructure logic
  • Interface or abstract class necessary for changing service in future

Please Like and Share if you found this insightful.
Thanks and Regards!
Yogesh Galav

Please Like and Share if you found this insightful

Top comments (0)