nexus-doctrine-dbal
Coroutine-aware Doctrine DBAL connection pool with HTTP middleware integration and actor-side binding.
What's in this package
ConnectionPool— per-thread, lazy pool with cooperative wait under SwooleSwooleChannel/FiberChannel— runtime-appropriate channel backendsConnectionScopeMiddleware+ConnectionResolver— injectConnectioninto HTTP handlers via PSR-15#[Transactional]+TransactionalDecorator— auto commit/rollback around handlersDoctrineBootstrap::enable()— setsSWOOLE_HOOK_ALLwhen Swoole is loadedActorPoolBinding— carry a pool reference into actor factoriesPoolExhaustedToServiceUnavailable— mapsPoolExhaustedExceptionto 503
Install
composer require nexus-actors/doctrine-dbal
Quick example
src/Bootstrap/WorkerSetup.php
use Monadial\Nexus\Doctrine\Dbal\Bootstrap\DoctrineBootstrap;
use Monadial\Nexus\Doctrine\Dbal\DoctrinePool;
use Monadial\Nexus\Doctrine\Dbal\Http\DoctrineHttp;
use Monadial\Nexus\Doctrine\Dbal\Pool\PoolConfig;
use Monadial\Nexus\Http\Handler\Resolver\ParamResolverRegistry;
DoctrineBootstrap::enable();
$pool = DoctrinePool::fromParams(
name: 'orders',
connParams: ['driver' => 'pdo_mysql', 'url' => $_ENV['DATABASE_URL']],
config: new PoolConfig(max: 16, minIdle: 2),
);
$registry = DoctrineHttp::install(
registry: new ParamResolverRegistry(),
middlewares: $middlewares,
connPool: $pool,
);
After DoctrineHttp::install(), handler __invoke() methods may declare a Connection parameter and receive the per-request lease automatically.
This package is separate from nexus-persistence-dbal (the event-sourcing/durable-state stores). Both can coexist.
See also
- Doctrine / overview
- Doctrine / connection pool
- nexus-doctrine-orm — ORM layer on top of this package