arabcoders / database
Standalone database toolkit for PDO with query building, ORM, schema migrations, and seeding.
v1.0.8
2026-09-01 05:07 UTC
Requires
- php: >=8.5
- ext-pdo: *
- psr/container: ^2.0
- psr/event-dispatcher: ^1.0
- psr/http-message: ^2.0
- psr/log: ^3.0
- psr/simple-cache: ^3.0
Requires (Dev)
- carthage-software/mago: ^1.3.0
- phpunit/phpunit: ^13.0
- rector/rector: ^2.5
README
arabcoders/database is a standalone PHP database package for PDO access, explicit SQL generation, and optional ORM, schema, migration, and seeding tools.
Install
composer require arabcoders/database
Requirements
- PHP 8.5 or newer.
- A PDO driver for
mysql,pgsql, orsqlite.
Choose a workflow
- Need
SELECT,INSERT,UPDATE, orDELETEstatements? Start with the query builder. - Need entities, repositories, relations, or validation? Read the ORM guide.
- Need model-backed schema changes or migration runs? Read schema and migrations.
- Need baseline data, fixtures, or repeatable setup? Read the seeding guide.
Connect and run a query
DialectFactory::fromPdo() selects the query dialect for the active PDO driver. Query values are bound by Connection.
<?php declare(strict_types=1); use arabcoders\database\Connection; use arabcoders\database\Dialect\DialectFactory; use arabcoders\database\Query\Condition; use arabcoders\database\Query\SelectQuery; $pdo = new \PDO('sqlite::memory:'); $db = new Connection($pdo, DialectFactory::fromPdo($pdo)); $rows = $db->fetchAll( (new SelectQuery('todos')) ->select(['id', 'title']) ->where(Condition::equals('status', 'open')) ->orderBy('id', 'DESC') ->limit(20) );
Capabilities
- Query objects for selects, writes, joins, predicates, subqueries, CTEs, set operations, locking, upserts, and
RETURNINGwhere the driver supports it. - Prepared query execution through
Connection, including row fetching, cursors, chunked results, raw SQL, transactions, nested savepoints, and retry behavior. - Attribute-defined entities with repositories, identity maps, soft deletes, relations, eager loading, lifecycle hooks, transforms, and validation.
- Declarative schema definitions, live-schema introspection, diffs, reversible SQL, blueprint migrations, migration checksums, locks, repair, squashing, and SQLite rebuild handling.
- Attribute-discovered seeders with dependencies, filters, run modes, transaction modes, dry runs, and execution history.
For driver behavior, feature flags, and custom SQL or schema dialects, see dialects and extensibility.