phramecms / database
Portable database abstraction for PhrameCMS — connection interface, fluent query builder, schema builder, and pluggable drivers.
Requires
- php: ^8.5
- doctrine/dbal: ^4.2
- phramecms/core: ^0.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- infection/infection: ^0.35.12
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^13.0
- spaze/phpstan-disallowed-calls: ^4.15
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-12-04 21:34:42 UTC
README
Database abstraction module for PhrameCMS, providing portable query building, schema DDL management, and pluggable storage drivers.
Responsibilities
ConnectionInterface: Unified abstraction for parameterized queries, transactions (beginTransaction,commit,rollback,transactional(),afterCommit()), and driver metadata.- Fluent
QueryBuilder: Safe, dialect-awareSELECT,INSERT,UPDATE, andDELETEbuilders using bound parameters exclusively (never string-interpolated user/agent values). - Portable
SchemaBuilder: Declarative DDL for creating, altering, and dropping tables, columns, primary/unique keys, foreign keys, and indexes across database engines — enabling modules likeconfig,user, andentityto manage tables portably. - Pluggable Drivers:
- Internal
doctrine/dbal-backed SQL driver (PhrameCms\Database\Driver\Dbal*) supporting SQLite, PostgreSQL, and MySQL/MariaDB. - Pure-PHP in-memory driver for ultra-fast, zero-extension unit and integration testing.
- Internal
- Migration Tracking: Lightweight module-scoped schema version tracking.
Zero Vendor Leak Boundary
phramecms/database follows the Hexagonal / Anti-Corruption Layer pattern: doctrine/dbal (^4.2) is encapsulated strictly as an internal SQL driver dependency behind PhrameCms\Database\Contract\*, avoiding SQL dialect/DDL reinvention with zero vendor lock-in across PhrameCMS:
Doctrine\DBAL\*classes and exceptions are strictly internal toPhrameCms\Database\Driver\Dbal*(and internal builders).Doctrine\DBAL\*types MUST NEVER appear inPhrameCms\Database\Contract\*, public DTOs, or public exceptions — always translate DBAL exceptions intoPhrameCms\Database\Exception\*.- Downstream modules (
config,user,entity) MUST depend only onPhrameCms\Database\Contract\*.
Explicitly Out of Scope
- ORM / ActiveRecord / CMS entity modeling (see
phramecms/entity);doctrine/ormis never used in PhrameCMS - Configuration sync or diffing (see
phramecms/config) - Exposing raw SQL execution to AI agents (agents interact only through typed Operations in higher-level modules)
Dependencies
- PHP
^8.5 doctrine/dbal(^4.2, internal SQL driver dependency — strictly encapsulated behindPhrameCms\Database\Contract\*)phramecms/core
Ecosystem
Part of the PhrameCMS multi-repo suite. See PhrameCMS/cms for the starter distribution and architecture docs.