rpodwika / designpatterns
PHP Design Patterns
Requires
- phpunit/phpunit: ^4.7
- satooshi/php-coveralls: dev-master
- sebastianbergmann/phpcov: 1.1.0
README
#Design Patterns for PHP
##Why
For my own pratice and to help other programmers I decided to implement several Design Patterns in PHP. I hope you like it and you will find it helpful. If you have any suggestions how can I write something better please create pull request or message me
##What are design patterns
Design problems are proven to work solutions for problems that often occur while writing applications.
##Why to use them
Because they solve problems. You do not need to invent solution that is already working. How many times during your programmer career you had this feeling that you already solved problem that you are facing now? Same goes with patterns you have problem that could be solved using specific pattern. Keep in mind that you should not force your code to fit in patterns. It should come out naturally. Firstly K.I.S.S.
##Implemented patterns
- Antipatterns
- Singleton - One global instance of a class
- Behavioral
- Adapter - adapt class behavior to new conditions without modifying source of original class
- Chain of responsibility - Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request
- Memento - Without violating encapsulation, capture and externalize an object's internal state
- Observer - Define one to many dependency between objects so that when one changes state, all its dependents are notified and updated automatically
- Proxy - Do some operations before giving access to origin object
- State - allow object to alter its behavior depending on current internal state change.
- Strategy - Define a family of algorithms and make them interchangeable.
- Creational
- Abstract Factory - Provides interface for creating families of objects working together without specification of concrete classes
- Factory - Define an interface for creating an object but let the subclasses decide which class to instantiate
- Structural
- Decorator - Attach additional object features dynamically without subclassing or modifying source class.
##To be implemented
- Builder
- Prototype
- Bridge
- Composite
- Facade
- Flyweight
- Command
- Interpreter
- Iterator
- Mediator
- Visitor