limingxinleo / swoft-trait-instance
基于Swoft的协程单例扩展
Installs: 1 927
Dependents: 1
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 1
Open Issues: 0
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-12-17 19:40:17 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 });