Design Pattern in Laravel and PHP #shorts

preview_player
Показать описание
Full course link is given below

Laravel uses following design pattern
Facades Pattern
Strategy Pattern
Repository Pattern
Factory pattern
Publisher Subscriber pattern
Provider Pattern

Design Patterns in Laravel you need to know
As we may know, PHP is a popular language among web developers and Backend. When mentioning PHP one cannot help but mention Laravel Framework. Laravel is an open source framework, created by Taylor Otwell . Laravel is designed based on the MVC pattern. Currently Laravel has released version 7.x has changed a lot compared to the first version from June 9, 2011.

I personally find that when learning any Framework, the first thing that we must know is which Frameworks there are Design Patterns. And Laravel, too, in its documents section, the author also cleverly arranges some Design Pattern on the first place and then the technicals in Laravel. Before going to list some Design Patterns you need to know in Laravel. Make sure you understand the concept of Design Pattern.

An easy-to-understand definition of a Design Pattern is as follows:

Design Pattern is a technique in object-oriented programming that programmers and researchers summarize standard designs for programming with common patterns.
Design Pattern is not a specific language, all programming languages ​​or its framework can apply Design Pattern.
Design Pattern helps projects to expand, limit bugs and maintain efficiency.
Design Pattern helps to unify the common code way so programmers will work effectively in groups to avoid having each person type 1 code.
Dependency Injection is a design pattern used to try to achieve

Dependency between objects when there is a dependency relationship between one object and another.

The Service Container in Laravel manages the dependency class and performs dependency injection

Binding: Register a class or interface with the container.

Contracts
Laravel Contracts is a set of interfaces that declare core services provided by the framework. For example, the contract Illuminate Contracts Queue Queue declares the methods needed for queue processing jobs, while Illuminate Contracts Mail Mailer declares the methods needed to send emails. Refer to contracts at illuminate / contracts .

The Repository Pattern is an intermediary layer between the Business Logic and Data Access layer, which makes data access tighter and more secure. The Repository acts as a connection layer between the Business layer and the Model of the application. Understandably, when t want to access data from the database, instead of writing processing code in the controller, we create a folder called Repository and then write the processing code here. Then we just inject it through __construct .

Why should I use the repository:

The code follows the design pattern so it is easy to maintain.
Increase the security and clarity of the code.
Bug will be less likely.
Avoid code duplication between team members.

Laravel Series Goal:
My goal for the Laravel series is to create a guide for beginners/Intermediate who want to learn Laravel. This guide will take you from the very beginning of an idea into a real deployable application.

#php
#phplaravel
#laravel
#webdevelopment
#cdl
#career_development_lab
#hadayatniazi
#coding
#technology#shorts
#short
Рекомендации по теме