My design pattern examples
This repo is various design patterns that I come across during development. This is meant for a reference and anyone interested in how certain patterns work in php.
Active Record Pattern
Example of an Active Record Pattern for centralize database access.
Adapter Pattern
Adapter pattern using Sendgrid API and Twilio.
Strategic Pattern (Composition over Inheritance)
This is located in src/Composition and shows the benefits of using composition over inheritance. This example uses a Duck and is based off of the Head First Design Patterns chapter 1.
Decorator Pattern
Example of a Decorator pattern using a Weapon and Damage modifiers as examples.
Factory Pattern
Example of using a Factory Pattern for object creation.
Observer Pattern
This is located in src/Observer and shows the benefits of using an Observer pattern. The example is taken from Head First Design Patterns using a Weather Data fictional program.
Singleton Pattern
Example of a very basic Singleton pattern. One of the easiest patterns to implement.