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.
这是一个php实现的设计模式的汇总,每个设计模式都有一个小栗子。
I think the problem with patterns is that often people do know them but don't know when to apply which.
我想关于设计模式的问题是:我们知道他但是不知道如何应用它们
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 的依赖
$ composer installRead more about how to install and use Composer on your local machine here.
关于更多如何使Composer请阅读更多 here.
To run the tests use phpunit:
$ ./vendor/bin/phpunitYou can optionally build and browse the documentation using Docker for Mac, Windows or Linux.
查看相应文档请查看:Docker for Mac, Windows or Linux.
Just run:
运行:
$ docker-compose up --buildGo to http://localhost:8080/README.html to read the generated documentation.
在 http://localhost:8080/README.html 查看生成文档。
The patterns can be structured in roughly three different categories. Please click on the 📓 for a full explanation of the pattern on Wikipedia.
设计模式大���有三个目录组成,点击链接查看详细的Wikipedia 解释 📓
- 适配器模式 📓
- 桥接模式 📓
- 组合模式 📓
- DataMapper 📓
- Decorator 📓
- DependencyInjection 📓
- Facade 📓
- FluentInterface 📓
- Flyweight 📓
- Proxy 📓
- Registry 📓
- 责任链模式 📓
- Command 📓
- Iterator 📓
- Mediator 📓
- Memento 📓
- NullObject 📓
- Observer 📓
- Specification 📓
- State 📓
- Strategy 📓
- TemplateMethod 📓
- Visitor 📓
- EAV 📓
- Repository
- ServiceLocator 📓 (is considered an anti-pattern! ⛔)
参考地址 : https://designpatternsphp.readthedocs.io/zh_CN/latest/README.html
有已经翻译完的地址请参考:https://learnku.com/docs/php-design-patterns/2018/translation-instructions/1486