Use of Solid Design Principle with Laravel 1

What is SOLID?

SOLID stands for ** of the first five object-oriented design (OOD) ** principles, known to Robert C. Martin as [Uncle Bob (].


Q — Single responsibility principle
O — On-off policy
L — Liskov substitute principle
I — Interface allocation policy
D — Addiction reduction Policy

Purpose of SOLID Design Principles:

  1. To make the code more sustainable.
  2. Make it easier to read and understand code.
  3. To make it easier to quickly expand the system with new functions without disrupting existing functions.
  4. Writing clean code.

Q — Let's Look at the Single Responsibility Policy.

According to the official definition of the principle of sole responsibility

A class must have only one reason to change.

What's that supposed to mean? Let's take an example from Laravel. On Controller
one Store(in question) Storeuse of method PostController) and Store The validate process will look like this.

Let's apply the Single responsibility policy here, Laravel removes the Form Request object from the package. Create a form request using an artisan command.

php artisan make:request StoreBlogPost

Creates a new request class app\Http\Request\StoreBlogPost.

Now we've created a form request PostControllerlet's change it to use it StoreBlogPost.

Automatically verifies the form request and returns verified requests. You can now use this method to verify your data as you wish.

In this article, we learned how to make the first letter of solid, S, the principle of sole responsibility. I hope this article was useful.


KARABAY A, 2020 . Use of Solid Design Principle with Laravel 1,

(Accessed September 20, 2020).

  Share this post

Comments (1)


Sign up for the email newsletter to be the first to know about my blog posts