Just messing with some PHP Design Patterns.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
README.md
activerecord.php
adapter.php
composer.json
composition.php
decorator.php
factory.php
observer.php
singleton.php

README.md

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.