Swoole runtime and connection drivers¶
Core 3 requires PHP 8.3 or newer and depends on small/collection 4.0.*, small/swoole-db 2.0.* and small/swoole-patterns 26.0.*.
The Core 3 development runtime targets Swoole 6.2.2 and OpenSwoole 26.2.0. Swoole is the default development implementation; the core repository can build its development image with OpenSwoole instead.
MySQL¶
Core 2.5 and newer uses native PDO because Swoole 6 removed Swoole\Coroutine\MySQL.
Required connection keys:
[
'type' => 'mysql',
'host' => 'mysql',
'port' => '3306',
'database' => 'app',
'user' => 'app',
'password' => 'secret',
'encoding' => 'utf8mb4',
'maxConnections' => 50,
]
Enable Swoole runtime hooks before database I/O. Never share a checked-out PDO connection between coroutines.
PostgreSQL¶
[
'type' => 'postgres',
'host' => 'postgres',
'port' => '5432',
'database' => 'app',
'user' => 'app',
'password' => 'secret',
'encoding' => 'UTF8',
'maxConnections' => 100,
]
The PostgreSQL connection uses pooled PgSql\Connection instances. Named parameters are rewritten by the driver adapter.
Core 3 also preserves explicitly assigned primary keys when persisting new PostgreSQL entities.
Small Swoole DB¶
This driver uses small/swoole-db and Swoole tables. It supports relational entity queries, scalar projections and persistence threads, but not every SQL database feature.
In particular, StatsQueryBuilder requires a SQL connection and is rejected by the Small Swoole DB adapter.
Raw statements¶
Connections accept driver-native statement objects rather than plain SQL strings.
use Small\Collection\Collection\Collection;
use Small\SwooleEntityManager\Database\Connection\Mysql\Bean\SqlStatement;
$statement = new SqlStatement(
'SELECT * FROM users WHERE id = :id',
new Collection(['id' => 42]),
);
$result = $connectionFactory->get()->execute($statement);
Use the statement class matching the configured driver.