Home > Backend Development > PHP Problem > What are the PHP design patterns?

What are the PHP design patterns?

(*-*)浩
Release: 2023-02-24 12:10:01
Original
3339 people have browsed it

According to purpose, there are currently 23 common PHP design patterns, which can be divided into the following three categories according to different usage goals:

What are the PHP design patterns?

Creational Patterns (5 types):

Design patterns used when creating objects. More specifically, the design pattern of the initialization object process. As programs become more complex, objects need to be created more flexibly while reducing dependencies during creation. Creating design patterns is a type of design pattern that solves this problem. (Recommended learning: PHP programming from entry to proficiency)

Single case mode [Singleton]

Factory mode[Factory]

Abstract factory mode[ AbstractFactory】

Builder Mode【Builder】

Prototype Mode【Prototype】

Structural Design Patterns (7 types):

Design patterns used for inheritance and interfaces. The structural design pattern is used to design function methods of new classes, reducing unnecessary class definitions and reducing code redundancy.

Adapter mode [Adapter]

Bridge mode [Bridge]

Composite mode [Composite]

Decorator mode [Decorator]

Facade Mode【Facade】

Proxy Mode【Proxy】

Flyweight Mode【Flyweight】

Behavioral Patterns (11 types):

Design patterns used for method implementation and corresponding algorithms, and are also the most complex design patterns. Behavioral design patterns are not only used to define the functional behavior of classes, but also for protocols and communications between different classes.

Strategy Mode【Strategy】

Template Method Mode【TemplateMethod】

Observer Mode【Observer】

Iterator Mode【Iterator】

Responsibility Chain Mode【ResponsibilityChain】

Command Mode【Command】

Memo Mode【Memento】

State Mode【State】

Visitor Mode【Visitor】

Mediator Mode【Mediator】

Interpreter Mode【Interpreter】

The above is the detailed content of What are the PHP design patterns?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template