Coder Social home page Coder Social logo

gabrielanhaia / php-design-patterns Goto Github PK

View Code? Open in Web Editor NEW
280.0 27.0 33.0 260 KB

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.

License: MIT License

Dockerfile 0.05% PHP 88.27% Makefile 11.69%
design-patterns php php8

php-design-patterns's Introduction

Logo - PHP 8.1 Design Patterns

Licence Package Stars Build Status Code Coverage

Every week a new Pattern + Article on www.medium.com/@anhaia.gabriel and www.medium.com/devwarlocks

PHP 8.2+ - Design Patterns

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.

Classification/Type

Type General Article Diagrams
Creational LEARN HERE ๐Ÿ“– HERE
Structural SOON HERE
Behavioral SOON SOON

Patterns implemented + Article

# ๐Ÿ“– Pattern Classification~Type Code Example / Implementation โœ๏ธ Article / Post ๐Ÿ“š Diagram
1 Abstract Factory Creational HERE SOON HERE
2 Builder Creational HERE SOON HERE
3 Factory Method Creational HERE LEARN HERE ๐Ÿ“– HERE
4 Prototype Creational HERE SOON HERE
5 Singleton Creational HERE SOON HERE
6 Object Pool Creational HERE SOON HERE
7 Adapter Structural HERE LEARN HERE ๐Ÿ“– HERE
8 Composite Structural HERE LEARN HERE ๐Ÿ“– HERE
9 Bridge Structural HERE SOON HERE
10 Facade Structural HERE LEARN HERE ๐Ÿ“– HERE
11 Decorator Structural HERE SOON HERE
12 Flyweight Structural HERE SOON HERE
13 Proxy Structural HERE SOON HERE
14 Template Method Behavioral HERE LEARN HERE ๐Ÿ“– SOON
15 Strategy Behavioral HERE LEARN HERE ๐Ÿ“– SOON
16 Iterator Behavioral HERE SOON SOON
17 Memento Behavioral HERE SOON SOON
18 Money X HERE LEARN HERE ๐Ÿ“– SOON
19 Null Object Behavioral HERE SOON SOON
20 Observer Behavioral HERE LEARN HERE ๐Ÿ“– SOON
21 State Behavioral HERE SOON SOON
22 Command Behavioral HERE SOON SOON
23 Chain of Responsibility Behavioral HERE SOON SOON
24 Interpreter Behavioral HERE SOON SOON
25 Mediator Behavioral HERE SOON SOON
26 Visitor Behavioral HERE LEARN HERE ๐Ÿ“– SOON

Dependencies

Running the project

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.

1. Build the container:

docker build -t design-patterns .

or if you prefer

make build

2. Run the following commands to test the design patterns:

make help

and then you will see the list of commands

3. You need to run the command with the pattern you want to test, for example:

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.

Additional Information

  • 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 called components; 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.

php-design-patterns's People

Contributors

gabrielanhaia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

php-design-patterns's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.