Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

DesignPatternsPHP

sample code for several design patterns in PHP

Subscribe to updates I use DesignPatternsPHP


Statistics on DesignPatternsPHP

Number of watchers on Github 14461
Number of open issues 11
Average time to close an issue about 1 month
Main language PHP
Average time to merge a PR 7 days
Open pull requests 21+
Closed pull requests 21+
Last commit over 1 year ago
Repo Created almost 8 years ago
Repo Last Updated over 1 year ago
Size 3.28 MB
Organization / Authordomnikl
Contributors84
Page Updated
Do you use DesignPatternsPHP? Leave a review!
View open issues (11)
View DesignPatternsPHP activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating DesignPatternsPHP for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

DesignPatternsPHP

Build 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 (most of them from Zend Framework, Symfony2 or Doctrine2 as I'm most familiar with this software).

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:

[optional] Using Docker

You can optionally run tests using Docker for Mac or Windows or native one for Linux. Just run:

docker-compose up

Install dependencies

$ composer install

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

If you are using Docker, you just have to run:

docker-compose run composer install

Running test suite

$ ./vendor/bin/phpunit

Patterns

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

Creational

Structural

Behavioral

More

Contribute

If you encounter any bugs or missing translations, please feel free to fork and send a pull request with your changes. To establish a consistent code quality, please check your code using PHP_CodeSniffer against PSR2 standard using ./vendor/bin/phpcs -p --standard=PSR2 --ignore=vendor ..

DesignPatternsPHP open issues Ask a question     (View All Issues)
  • almost 3 years Design pattern for version 5.6
  • over 4 years Version in other languages?
DesignPatternsPHP open pull requests (View All Pulls)
  • What about making things more comprehensive
  • Upgrade to PHP7 strict mode
  • added flyweight pattern
  • Comment updates in AbstractFactory
  • German translation
  • Fixed PHPDoc in accordance with the interface
  • Some translations to brazilian portuguese
  • State container Pattern
  • Update README.rst
  • Make the method abstract on the Bridhe pattern
  • ISP
  • Provisioning upgrade
  • add LearnNote/Strategy
  • State pattern is maintainable
  • RendererDecorator implement RenderableInterface
  • RendererDecorator class should implement RenderableInterface.
  • change Proxy pattern
  • Fix missing space in pt_BR translation
  • Fixes for Turkish translation files.
  • Lazy Loading
  • Add composer image to docker-compose.yml
DesignPatternsPHP list of languages used
More projects by domnikl View all
Other projects in PHP