2013-08-08 16:48:52 +05:30
2013-05-11 20:54:21 +02:00
2013-05-12 12:30:42 +02:00
2013-05-12 22:20:12 +02:00
2013-05-11 22:18:12 +02:00
2013-05-11 22:18:12 +02:00
2013-07-03 08:39:51 +02:00
2013-05-12 14:32:16 +02:00
2011-08-23 11:52:46 +02:00
2013-05-13 21:57:52 +02:00
2013-05-08 01:06:11 +08:00
2013-07-03 12:00:55 +02:00
2013-08-24 00:36:54 +02:00
2013-05-10 21:49:22 +02:00
2013-07-03 12:00:55 +02:00
2011-09-03 12:57:28 +02:00
2013-05-12 11:13:37 +02:00
2013-05-10 19:12:02 +02:00
2011-10-30 11:51:39 +01:00
2013-05-10 19:51:19 +02:00
2013-09-03 14:35:47 +02:00

design patterns in PHP

Build Status

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.

The patterns can be structured in roughly three different categories:

Creational

  • (AbstractFactory)[tree/master/AbstractFactory]
  • (Builder)[tree/master/Builder]
  • (SimpleFactory)[tree/master/SimpleFactory]
  • (FactoryMethod)[tree/master/FactoryMethod]
  • (StaticFactory)[tree/master/StaticFactory]
  • (Prototype)[tree/master/Prototype]
  • (Singleton)[tree/master/Singleton] (is considered an anti-pattern! )
  • (Multiton)[tree/master/Multiton] (is considered an anti-pattern! )

Structural

  • (Adapter)[tree/master/Adapter]
  • (Composite)[tree/master/Composite]
  • (Decorator)[tree/master/Decorator]
  • (Facade)[tree/master/Facade]
  • (Proxy)[tree/master/Proxy]
  • (Registry)[tree/master/Registry]
  • (FluentInterface)[tree/master/FluentInterface]
  • (DataMapper)[tree/master/DataMapper]
  • (DependencyInjection)[tree/master/DependencyInjection]

Behavioral

  • (ChainOfResponsibilities)[tree/master/ChainOfResponsibilities]
  • (Command)[tree/master/Command]
  • (Iterator)[tree/master/Iterator]
  • (Mediator)[tree/master/Mediator]
  • (NullObject)[tree/master/NullObject]
  • (Observer)[tree/master/Observer]
  • (StatusPattern)[tree/master/StatusPattern]
  • (Strategy)[tree/master/Strategy]
  • (TemplateMethod)[tree/master/TemplateMethod]
  • (Visitor)[tree/master/Visitor]

Please feel free to fork and extend existing or add your own examples!

Languages
PHP 85.3%
Python 8%
Makefile 6.2%
Dockerfile 0.5%