ervin-meng / php-design-patterns
PHP设计模式
Package info
github.com/ervin-meng/PHPDesignPatterns
Type:application
pkg:composer/ervin-meng/php-design-patterns
dev-master
2020-09-01 09:12 UTC
Requires
- php: >=5.5.0
This package is auto-updated.
Last update: 2026-03-01 00:32:41 UTC
README
代码示例
<?php use PHPDesignPatterns\Creational\Builder\Builder; use PHPDesignPatterns\Creational\Builder\Director; use PHPDesignPatterns\Creational\Singleton\Singleton; use PHPDesignPatterns\Creational\Prototype\Prototype; //原型模式 $prototype = new Prototype(); $prototype->setStatus(1); $prototypeOne = clone $prototype; echo $prototypeOne->getStatus(); //单例模式 $instance = Singleton::getInstance(); //创建者模式 $director = new Director(); $builder = new Builder(); $director->build($builder);