Installation
The package pulls in no dependencies: PHP 8.4+ and nothing else. Swoole is optional — what depends on it is not whether the package works, but whether the pool is a real one.
Composer
composer require flytachi/winter-cpoolRequirements
| Requirement | Role |
|---|---|
| PHP 8.4+ | required |
ext-swoole |
optional — enables the coroutine pool |
The package has no runtime dependencies whatsoever: no PSR interfaces, no drivers. Everything that knows about a database or Redis lives in your adapter.
What Swoole gives and does not give
The package detects the extension itself and behaves differently:
| Runtime | What is used | Behaviour |
|---|---|---|
| Swoole active | ConnectionPool |
a set of connections, one per coroutine, waiting on a channel |
| No Swoole | SingleConnection |
one lazy connection with the same contract |
The second is not a stub. Under PHP-FPM or in a plain CLI script the process serves one unit of work at a time and the pool has nothing to distribute; one connection with liveness checks and a lifetime is the right answer for such a runtime.
No branching in your code
Both classes implement the same idea, so a facade picks the right one once at initialisation and the application code never knows. How that is done — in the Quick start.
For working on the package
If you are changing CPool itself, ext-swoole becomes mandatory: behaviour under
concurrency is verified with live coroutines, and without the extension those tests will
not run.
XDEBUG_MODE=off composer testXDEBUG_MODE=off is not a whim here. Xdebug’s function observers do not survive
coroutine stacks: the tests pass, then the process crashes on shutdown — the report says
OK, the exit code is 139. Details are in the package’s CONTRIBUTING.md.
Verify the installation
<?php
require 'vendor/autoload.php';
use Flytachi\Winter\CPool\PoolPolicy;
$policy = PoolPolicy::default();
echo $policy->maximumPoolSize, PHP_EOL; // 10
echo var_export($policy->housekeepingEnabled(), true), PHP_EOL; // false
echo var_export(extension_loaded('swoole'), true), PHP_EOL;The third line is the one that tells you which mode you get: true — the coroutine
pool, false — a single connection.
Next
- Quick start — the adapter, the pool, borrow and release
- Writing an adapter — the three methods in detail