marko / database-readwrite
Read/write connection splitting for the Marko Framework database layer
0.11.0
2026-10-06 13:35 UTC
Requires
- php: ^8.5
- ext-pdo: *
- marko/core: 0.11.0
- marko/database: 0.11.0
Requires (Dev)
- marko/testing: 0.11.0
- pestphp/pest: ^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Routes reads to replicas, writes to primary --- drop-in decorator for any Marko database driver.
Installation
composer require marko/database-readwrite
Quick Example
<?php declare(strict_types=1); use Marko\Config\Env; return [ 'driver' => 'readwrite', 'connections' => [ 'write' => [ 'driver' => 'pgsql', 'host' => Env::string('DB_WRITE_HOST', 'localhost'), 'port' => Env::int('DB_WRITE_PORT', 5432, min: 1, max: 65535), 'database' => Env::string('DB_DATABASE', 'marko'), 'username' => Env::string('DB_USERNAME', 'postgres'), 'password' => Env::string('DB_PASSWORD', ''), ], 'read' => [ [ 'driver' => 'pgsql', 'host' => Env::string('DB_READ_HOST', 'replica-1'), 'port' => Env::int('DB_READ_PORT', 5432, min: 1, max: 65535), 'database' => Env::string('DB_DATABASE', 'marko'), 'username' => Env::string('DB_USERNAME', 'postgres'), 'password' => Env::string('DB_PASSWORD', ''), ], ], 'read_strategy' => 'random', ], ];
Documentation
Full usage, configuration, API reference, and examples: marko/database-readwrite