Practical examples of design patterns in PHP

I’ve been doing a lot of reading into design patterns and currently half way through the Head First Design Patterns book. Firstly, I’d like to mention that the book is a great read and explains the patterns in such a way that it’s fairly simple to understand and grasp the concepts. The book explains how each pattern is implemented in Java, along with, class diagrams and great annotations.

As we all know, Java is an object oriented programming language and therefore, most of the same principles and structure can be applied in PHP. With this being said, I wanted to find some practical examples of how each pattern is implemented in PHP. Luckily, I found a great GitHub repository from Dominik Liebler that lists each pattern, from strategy to service locator to decorator – a lot of the common patterns are listed in this GitHub repository https://github.com/domnikl/DesignPatternsPHP

I found it particularly useful looking at the unit tests to see the entry point for each pattern and how the different objects interact with each other.

Leave a comment