Every week a new Pattern + Article on www.medium.com/@anhaia.gabriel and www.medium.com/devwarlocks
This repository was created to show the implementation of various Design Patterns using PHP 8.2. There is no dependency on a framework, and the examples are the most real as possible based on my own experiences solving real-life problems. Applying the design pattern and its concept in any PHP project will be effortless once you learn the design pattern and its concept.
Type | General Article | Diagrams |
---|---|---|
LEARN HERE π | HERE | |
SOON | HERE | |
SOON | SOON |
# | π Pattern | Classification~Type | Code Example / Implementation | βοΈ Article / Post π | Diagram |
---|---|---|---|---|---|
1 | Abstract Factory | HERE | SOON | HERE | |
2 | Builder | HERE | SOON | HERE | |
3 | Factory Method | HERE | LEARN HERE π | HERE | |
4 | Prototype | HERE | SOON | HERE | |
5 | Singleton | HERE | SOON | HERE | |
6 | Object Pool | HERE | SOON | HERE | |
7 | Adapter | HERE | LEARN HERE π | HERE | |
8 | Composite | HERE | LEARN HERE π | HERE | |
9 | Bridge | HERE | SOON | HERE | |
10 | Facade | HERE | LEARN HERE π | HERE | |
11 | Decorator | HERE | SOON | HERE | |
12 | Flyweight | HERE | SOON | HERE | |
13 | Proxy | HERE | SOON | HERE | |
14 | Template Method | HERE | LEARN HERE π | SOON | |
15 | Strategy | HERE | LEARN HERE π | SOON | |
16 | Iterator | HERE | SOON | SOON | |
17 | Memento | HERE | SOON | SOON | |
18 | Money | HERE | LEARN HERE π | SOON | |
19 | Null Object | HERE | SOON | SOON | |
20 | Observer | HERE | LEARN HERE π | SOON | |
21 | State | HERE | SOON | SOON | |
22 | Command | HERE | SOON | SOON | |
23 | Chain of Responsibility | HERE | SOON | SOON | |
24 | Interpreter | HERE | SOON | SOON | |
25 | Mediator | HERE | SOON | SOON | |
26 | Visitor | HERE | LEARN HERE π | SOON |
I strongly recommend that you follow the articles (links above) and run them with Docker. It will be much easier, and you need to install Docker on your computer, independent of the OS you are using. With a few commands, you will run/test all the Design Patterns implemented throughout the course.
docker build -t design-patterns .
or if you prefer
make build
make help
and then you will see the list of commands
make strategy
4. In case you want to see a short description of the pattern, you can run the make PATTERN_NAME-help
, for example:
make strategy-help
With that, you should see a one-line description of the pattern.
- If you take a look at the examples in the blog or inside the folders
/src/{$pattern_name}/
you will notice that almost All the examples contain a folder calledcomponents
; those folders are the files/classes used to demonstrate how to use each pattern. Never consider what is in there as part of the pattern! They are not examples to be followed in your applications.