If you know a couple of things about good development and best practices, you have probably heard about software design patterns.

You can define them as useful solution templates for a certain kind of problem, or to be more precise:

In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.

Now, let’s focus on the second sentence.

A design pattern is not something that can be transformed directly into source code.

That’s the most important part because it explains many things. It is not something you learn specifically for Laravel or maybe for a certain language.

Absolutely, once you learned about design patterns, it is for life!

many people strongly believe in the Single Responsibility Principle, so every class must do one and only one thing. Nothing more!

Let’s be clear; I don’t want to bore you by adding my useless opinion in this long-time debate.

I will introduce a specific design pattern that can be really useful for improving a Laravel application—the repository pattern.