Search by

phramecms / database

TLyngeJ

Portable database abstraction for PhrameCMS — connection interface, fluent query builder, schema builder, and pluggable drivers.

Package info

github.com/PhrameCMS/database

pkg:composer/phramecms/database

Statistics

Installs: 52

Dependents: 5

Suggesters: 1

Stars: 0

Open Issues: 0

v0.1.0 2026-12-04 21:04 UTC

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-aware SELECT, INSERT, UPDATE, and DELETE builders 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 like config, user, and entity to 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.
  • 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 to PhrameCms\Database\Driver\Dbal* (and internal builders).
  • Doctrine\DBAL\* types MUST NEVER appear in PhrameCms\Database\Contract\*, public DTOs, or public exceptions — always translate DBAL exceptions into PhrameCms\Database\Exception\*.
  • Downstream modules (config, user, entity) MUST depend only on PhrameCms\Database\Contract\*.

Explicitly Out of Scope

  • ORM / ActiveRecord / CMS entity modeling (see phramecms/entity); doctrine/orm is 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 behind PhrameCms\Database\Contract\*)
  • phramecms/core

Ecosystem

Part of the PhrameCMS multi-repo suite. See PhrameCMS/cms for the starter distribution and architecture docs.