All projects

Learning · 2022 Project 18 of 20

PHP Design Patterns

Design patterns and SOLID principles from a C# course, rewritten in PHP 8.1 with notes.

At a glance

Role
Author
Period
2022
Status
Archived
Technologies
2 technologies

During a course on design patterns in C# I rewrote every example in PHP and gave each one a short README: what the pattern solves and where PHP differs. The repository covers creational, structural and behavioural patterns, plus the five SOLID principles.

What was interesting

  • PHP is not C#. PHP has no nested classes, no sealed keyword and no properties in interfaces, so the stepwise builder, the inner factory and the decorator with a default interface implementation cannot be ported one to one. Two examples stayed in C# for comparison.
  • A fluent builder with inheritance. In C# an inherited fluent builder is complicated; in PHP the self return type is enough.
  • New in PHP 8.1. Enums instead of constants for coordinate systems, token types in the lexer or kinds of drinks in the abstract factory.

Built with

  • PHP 8.1
  • C#

Keyboard shortcuts.

Keyboard shortcuts for this site. They stay quiet while you type into a form.

This site

?
This help
g
12-column grid, components and page metrics
d
Appearance: system, light, dark, Linkin Park
Ctrl P
Print the CV instead of the website
Esc
Close the dialog or the grid

The blue dot after the name can be grabbed and thrown.

Linkin Park

l setlist lp
The setlist, songs by album
papercut
The page tears like paper
numb
The site goes numb for a few seconds
faint
The page faints and comes round
meteora
A meteor shower and a direct hit on the dot after the name
fromzero emily
The site fades down to zero and is reborn, with thanks to Emily Armstrong
concert koncert
Concert: the site runs through the colours of every album
castleofglass
The page turns to glass, cracks and shatters
iridescent
Headings and dots shimmer in rainbow colours
breakingthehabit
Whatever is on screen falls apart and snaps back
intheend
End credits, like at the cinema
victim morethevictim
The site breaks up in a glitch and stays distorted (until a reload, another word or Esc)
finalmasquerade
A masquerade mask over the whole site, the camera flies through an eye
lost
Off to the 404 page

Type the words anywhere outside the form; case and spaces do not matter. With reduced motion you get a short note instead.

On a phone, five taps on the blue dot after the name open the setlist.