limingxinleo / swoft-trait-instance
基于Swoft的协程单例扩展
1.0.1
2018-08-20 11:00 UTC
Requires
- php: >=7.0
- swoft/framework: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- swoft/swoole-ide-helper: dev-master
This package is auto-updated.
Last update: 2024-10-17 19:20:59 UTC
README
基于Swoft的协程单例扩展
单例模式Trait
<?php use Xin\Swoft\Traits\InstanceTrait; class Incr { use InstanceTrait; public $incr = 0; public function incr() { return ++$this->incr; } public function get() { return $this->incr; } } echo Incr::getInstance()->incr(); // 1 go(function(){ echo Incr::getInstance()->incr(); // 1 });