设计模式面试题php,设计模式的PHP示例代码

DesignPatternsPHP

68747470733a2f2f7472617669732d63692e6f72672f646f6d6e696b6c2f44657369676e5061747465726e735048502e7376673f6272616e63683d6d617374657268747470733a2f2f72656164746865646f63732e6f72672f70726f6a656374732f64657369676e7061747465726e737068702f62616467652f3f76657273696f6e3d6c617465737468747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d70617970616c2d626c75652e7376673f7374796c653d666c61742d737175617265

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.

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:

$ composer install

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

To run the tests use phpunit:

$ ./vendor/bin/phpunit

using Docker (optional)

You can optionally build and browse the documentation using Docker for Mac, Windows or Linux.

Just run:

$ docker-compose up

Go to http://localhost:8080/README.html to read the generated documentation.

To only install the dependencies, use docker-compose like this:

$ docker-compose run php php composer.phar install

Patterns

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

ServiceLocator 📓 (is considered an anti-pattern!

⛔️)

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 ..

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值