Skip to content
sample code for several design patterns in PHP 7.4
PHP Python Makefile Dockerfile
Branch: master
Clone or download

Latest commit

Latest commit 6e1000f Jun 7, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows aaargh Dec 15, 2019
Behavioral update deps & install rector Dec 14, 2019
Creational no longer list Singleton and ServiceLocator as anti-pattern, still ad… Apr 17, 2020
More update deps & install rector Dec 14, 2019
Structural update deps & install rector Dec 14, 2019
locale Merge branch 'master' of https://github.com/domnikl/DesignPatternsPHP Jun 7, 2020
.gitignore remove Interface-Suffix Aug 19, 2019
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md Aug 23, 2019
Dockerfile #376 use multi-stage Docker build Apr 3, 2020
LICENSE Update LICENSE Jan 1, 2020
Makefile #376 use multi-stage Docker build Apr 3, 2020
README.md no longer list Singleton and ServiceLocator as anti-pattern, still ad… Apr 17, 2020
README.rst move from Travis to Github Actions Dec 15, 2019
check-refs-readmes sort output for check-refs-readmes Sep 12, 2019
composer.json update packages Apr 3, 2020
composer.lock update packages Apr 3, 2020
conf.py refactored .gitignore and fixed copyrights Aug 17, 2019
docker-compose.yml #376 use multi-stage Docker build Apr 3, 2020
phpcs.xml.dist use flyeralarm/php-code-validator to validate PHP code Aug 26, 2019
phpunit.xml.dist update to phpunit8 Aug 17, 2019
psalm.xml add psalm and travis check Aug 31, 2019

README.md

DesignPatternsPHP

Build Status Documentation Status Donate

Read the Docs of DesignPatternsPHP or Download as PDF/Epub

This is a collection of known design patterns and some sample code how to implement them in PHP. Every pattern has a small list of examples.

I think the problem with patterns is that often people do know them but don't know when to apply which.

Installation

You should look at and run the tests to see what happens in the example. To do this, you should install dependencies with Composer first:

$ composer install

Read more about how to install and use Composer on your local machine here.

To run the tests use phpunit:

$ ./vendor/bin/phpunit

using Docker (optional)

You can optionally build and browse the documentation using Docker for Mac, Windows or Linux.

Just run:

$ docker-compose up --build

Go to http://localhost:8080/README.html to read the generated documentation.

Patterns

The patterns can be structured in roughly three different categories. Please click on the 📓 for a full explanation of the pattern on Wikipedia.

Creational

Structural

Behavioral

More

You can’t perform that action at this time.