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#