DesignPatternsPHP/README.md

91 lines
5.0 KiB
Markdown
Raw Normal View History

2013-09-04 10:11:18 +02:00
# DesignPatternsPHP
2011-08-30 12:34:45 +02:00
2019-12-15 20:08:59 +01:00
[![Build Status](https://github.com/domnikl/DesignPatternsPHP/workflows/CI/badge.svg)](https://github.com/domnikl/DesignPatternsPHP/actions)
2018-06-14 23:02:18 +02:00
[![Documentation Status](https://readthedocs.org/projects/designpatternsphp/badge/?version=latest)](https://readthedocs.org/projects/designpatternsphp/?badge=latest)
2017-12-27 08:26:12 +01:00
[![Donate](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square)](https://paypal.me/DominikLiebler)
2013-05-16 09:19:02 +02:00
2015-04-05 03:29:00 +02:00
[Read the Docs of DesignPatternsPHP](http://designpatternsphp.readthedocs.org)
or [Download as PDF/Epub](https://readthedocs.org/projects/designpatternsphp/downloads/)
2015-04-02 00:57:18 +02:00
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.
2011-08-30 12:34:45 +02:00
I think the problem with patterns is that often people do know them but don't know when to apply which.
2011-08-30 12:34:45 +02:00
## 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:
```bash
$ composer install
```
Read more about how to install and use `Composer` on your local machine [here](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx).
2018-07-08 17:33:49 +02:00
To run the tests use `phpunit`:
```bash
2018-07-08 17:33:49 +02:00
$ ./vendor/bin/phpunit
```
2018-07-08 17:33:49 +02:00
## using Docker (optional)
You can optionally build and browse the documentation using [Docker for Mac, Windows or Linux](https://docs.docker.com/compose/install/).
2018-07-08 17:33:49 +02:00
Just run:
2018-07-08 17:38:04 +02:00
```bash
2019-09-12 22:00:27 +02:00
$ docker-compose up --build
2018-07-08 17:33:49 +02:00
```
Go to [http://localhost:8080/README.html](http://localhost:8080/README.html) to read the generated documentation.
2013-09-04 10:11:18 +02:00
## Patterns
The patterns can be structured in roughly three different categories. Please click on the [:notebook:](http://en.wikipedia.org/wiki/Software_design_pattern) for a full explanation of the pattern on Wikipedia.
2013-09-03 14:35:47 +02:00
2014-04-16 14:51:11 -03:00
### [Creational](Creational)
* [AbstractFactory](Creational/AbstractFactory) [:notebook:](http://en.wikipedia.org/wiki/Abstract_factory_pattern)
* [Builder](Creational/Builder) [:notebook:](http://en.wikipedia.org/wiki/Builder_pattern)
* [FactoryMethod](Creational/FactoryMethod) [:notebook:](http://en.wikipedia.org/wiki/Factory_method_pattern)
* [Pool](Creational/Pool) [:notebook:](http://en.wikipedia.org/wiki/Object_pool_pattern)
2014-05-02 12:33:44 -03:00
* [Prototype](Creational/Prototype) [:notebook:](http://en.wikipedia.org/wiki/Prototype_pattern)
* [SimpleFactory](Creational/SimpleFactory)
* [Singleton](Creational/Singleton) [:notebook:](http://en.wikipedia.org/wiki/Singleton_pattern)
2014-05-02 12:33:44 -03:00
* [StaticFactory](Creational/StaticFactory)
2014-04-16 14:51:11 -03:00
### [Structural](Structural)
* [Adapter](Structural/Adapter) [:notebook:](http://en.wikipedia.org/wiki/Adapter_pattern)
2014-05-02 12:33:44 -03:00
* [Bridge](Structural/Bridge) [:notebook:](http://en.wikipedia.org/wiki/Bridge_pattern)
2014-04-16 14:51:11 -03:00
* [Composite](Structural/Composite) [:notebook:](http://en.wikipedia.org/wiki/Composite_pattern)
* [DataMapper](Structural/DataMapper) [:notebook:](http://en.wikipedia.org/wiki/Data_mapper_pattern)
* [Decorator](Structural/Decorator) [:notebook:](http://en.wikipedia.org/wiki/Decorator_pattern)
* [DependencyInjection](Structural/DependencyInjection) [:notebook:](http://en.wikipedia.org/wiki/Dependency_injection)
* [Facade](Structural/Facade) [:notebook:](http://en.wikipedia.org/wiki/Facade_pattern)
* [FluentInterface](Structural/FluentInterface) [:notebook:](http://en.wikipedia.org/wiki/Fluent_interface)
2016-06-04 01:16:55 +02:00
* [Flyweight](Structural/Flyweight) [:notebook:](https://en.wikipedia.org/wiki/Flyweight_pattern)
2014-04-16 14:51:11 -03:00
* [Proxy](Structural/Proxy) [:notebook:](http://en.wikipedia.org/wiki/Proxy_pattern)
* [Registry](Structural/Registry) [:notebook:](http://en.wikipedia.org/wiki/Service_locator_pattern)
### [Behavioral](Behavioral)
* [ChainOfResponsibilities](Behavioral/ChainOfResponsibilities) [:notebook:](http://en.wikipedia.org/wiki/Chain_of_responsibility_pattern)
* [Command](Behavioral/Command) [:notebook:](http://en.wikipedia.org/wiki/Command_pattern)
* [Iterator](Behavioral/Iterator) [:notebook:](http://en.wikipedia.org/wiki/Iterator_pattern)
* [Mediator](Behavioral/Mediator) [:notebook:](http://en.wikipedia.org/wiki/Mediator_pattern)
2014-06-09 09:43:06 +01:00
* [Memento](Behavioral/Memento) [:notebook:](http://en.wikipedia.org/wiki/Memento_pattern)
2014-04-16 14:51:11 -03:00
* [NullObject](Behavioral/NullObject) [:notebook:](http://en.wikipedia.org/wiki/Null_Object_pattern)
* [Observer](Behavioral/Observer) [:notebook:](http://en.wikipedia.org/wiki/Observer_pattern)
* [Specification](Behavioral/Specification) [:notebook:](http://en.wikipedia.org/wiki/Specification_pattern)
* [State](Behavioral/State) [:notebook:](http://en.wikipedia.org/wiki/State_pattern)
* [Strategy](Behavioral/Strategy) [:notebook:](http://en.wikipedia.org/wiki/Strategy_pattern)
* [TemplateMethod](Behavioral/TemplateMethod) [:notebook:](http://en.wikipedia.org/wiki/Template_method_pattern)
* [Visitor](Behavioral/Visitor) [:notebook:](http://en.wikipedia.org/wiki/Visitor_pattern)
### [More](More)
2015-10-19 22:04:57 -02:00
* [EAV](More/EAV) [:notebook:](https://en.wikipedia.org/wiki/Entity%E2%80%93attribute%E2%80%93value_model)
2019-08-30 07:56:18 +02:00
* [Repository](More/Repository)
* [ServiceLocator](More/ServiceLocator) [:notebook:](http://en.wikipedia.org/wiki/Service_locator_pattern)