MixPHP 是一个 PHP 命令行模式开发框架;基于 Vega 驱动的 HTTP 可以同时支持 Swoole、WorkerMan、FPM、CLI-Server 生态,并且可以无缝切换;V3 是一个高度解耦的版本,整体代码基于多个独立的模块构建,即便用户不使用我们的脚手架,也可以使用这些独立模块,并且全部模块都支持原生开发。例如:你可以只使用 mix/vega 来搭配 laravel orm 使用
size = $size;
}
public function setColor($color) {
$this->color = $color;
}
public function setType($type) {
$this->type = $type;
}
public function toString() {
ob_start();
echo 'Size: ', $this->size , '
';
echo 'Color: ', $this->color , '
';
echo 'Type: ', $this->type , '
';
return ob_get_clean();
}
}
// 分别调用每个方法并不是最佳的做法
$product = new Product();
$product->setSize(100);
$product->setColor('red');
$product->setType('shirt');
// echo $product;
// -----------------------------------------------------------
/**
* 建造者模式
* 将一个复杂对象的构建与它的表示分离,使同样的构建过程可以创建不同的表示
*/
class ProductBuilder
{
private $product;
private $configs;
public function construct($cfgs) {
$this->configs = $cfgs;
$this->product = new Product();
}
/**
* 构建对象
*/
public function buildProduct() {
$this->product->setSize($this->configs['size']);
$this->product->setColor($this->configs['color']);
$this->product->setType($this->configs['type']);
}
public function getProduct() {
return $this->product;
}
}
$cfgs = array('size'=>100,'color'=>'blue','type'=>'shirt');
$builder = new ProductBuilder($cfgs);
$builder->buildProduct();
echo $builder->getProduct();










