moln / swoole-doctrine-pool
Using doctrine pool for swoole
0.1.1
2024-11-26 10:43 UTC
Requires
- php: >=8.1
- ext-swoole: *
- doctrine/dbal: ^3.8 | ^4.2
Requires (Dev)
- doctrine/orm: ^3.3
- laminas/laminas-servicemanager: ^4.3
- phpunit/phpunit: ^11.4
- roave/psr-container-doctrine: ^5.5
- slevomat/coding-standard: ^8.15
- swoole/ide-helper: ^5.1
README
Installation
composer require moln/swoole-doctrine-pool
Usage
use Moln\SwooleDoctrinePool\DoctrineDbalPool; class DemoController { public function __construct(private DoctrineDbalPool $pool) {} public function handle() { $result = []; $dbPool = $this->pool; for ($i = 0; $i < 10; $i++) { go(function () use ($dbPool, &$result) { $conn = $dbPool->get(); $result[] = $conn->executeQuery('SELECT now() as "now", sleep(1)')->fetchOne(); $dbPool->put($conn); }); } return $result; } }