gabrielanhaia/php-design-patterns
关于
Learn how to implement the most important Design Patterns into your PHP application. This project uses PHP 8+. it has examples for each Pattern and an Article explaining how to use them step by step, their advantages, and disadvantages.
学习与教育实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
PHP 8.2+ Design Patterns
Learn how to implement the most important Design Patterns in PHP. This repository contains 26 patterns with real-world examples, runnable code, class diagrams, and companion articles.
No framework dependencies. Every example is based on real problems and can be applied directly to any PHP project.
New patterns and articles published on Medium @devwarlocks and Medium @anhaia.gabriel.
Table of Contents
- Patterns Overview
- Creational Patterns
- Structural Patterns
- Behavioral Patterns
- Other Patterns
- Getting Started
- Additional Information
- License
Patterns Overview
| Type | General Article | Diagrams |
|---|---|---|
| Learn here | Diagrams | |
| SOON | Diagrams | |
| SOON | Diagrams |
Creational Patterns
| # | Pattern | Code | Article | Diagram |
|---|---|---|---|---|
| 1 | Abstract Factory | Source | SOON | Diagram |
| 2 | Builder | Source | SOON | Diagram |
| 3 | Factory Method | Source | Read | Diagram |
| 4 | Prototype | Source | SOON | Diagram |
| 5 | Singleton | Source | SOON | Diagram |
| 6 | Object Pool | Source | SOON | Diagram |
Structural Patterns
| # | Pattern | Code | Article | Diagram |
|---|---|---|---|---|
| 7 | Adapter | Source | Read | Diagram |
| 8 | Composite | Source | Read | Diagram |
| 9 | Bridge | Source | SOON | Diagram |
| 10 | Facade | Source | Read | Diagram |
| 11 | Decorator | Source | SOON | Diagram |
| 12 | Flyweight | Source | SOON | Diagram |
| 13 | Proxy | Source | SOON | Diagram |
Behavioral Patterns
| # | Pattern | Code | Article | Diagram |
|---|---|---|---|---|
| 14 | Template Method | Source | Read | Diagram |
| 15 | Strategy | Source | Read | Diagram |
| 16 | Iterator | Source | SOON | Diagram |
| 17 | Memento | Source | SOON | Diagram |
| 19 | Null Object | Source | SOON | Diagram |
| 20 | Observer | Source | Read | Diagram |
| 21 | State | Source | SOON | Diagram |
| 22 | Command | Source | SOON | Diagram |
| 23 | Chain of Responsibility | Source | SOON | Diagram |
| 24 | Interpreter | Source | SOON | Diagram |
| 25 | Mediator | Source | SOON | Diagram |
| 26 | Visitor | Source | Read | Diagram |
Other Patterns
| # | Pattern | Code | Article | Diagram |
|---|---|---|---|---|
| 18 | Money | Source | Read | Diagram |
Getting Started
Prerequisites
1. Build the container
make build
or
docker build -t design-patterns .
2. List all available patterns
make help
3. Run a pattern
make strategy
4. Get a short description of a pattern
make strategy-help
Additional Information
If you look at the examples inside each /src/{pattern_name}/ folder, you'll notice most contain a components subfolder. These files are supporting classes used to demonstrate the pattern in action. They are not part of the pattern itself and should not be taken as examples to follow in your own applications.
License
This project is licensed under the MIT License - see the LICENSE file for details.
If this project helped you learn, consider giving it a star or buying me a coffee.
探索相关项目
加载中…