Download the PHP package waffle-commons/data without Composer
On this page you can find all versions of the php package waffle-commons/data. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download waffle-commons/data
More information about waffle-commons/data
Files in waffle-commons/data
Package data
Short Description The data and persistence layer for Waffle Commons (RFC-022): a warm connection pool, a backend-agnostic query AST, and parameterized SQL / CQL / MongoDB / Firestore / key-value / GraphQL compilers for resident-worker mode.
License MIT
Informations about the package data
Waffle Data Component
Release:
0.1.0-beta7|CHANGELOG.md
The data & persistence layer for the Waffle Framework (RFC-022). Built for FrankenPHP resident-worker mode: a warm connection pool, a backend-agnostic query AST, parameterized SQL / Firestore compilers, a property-hook hydrator, and a stateless SQL migration runner. No stateful ORM, no identity map, no change tracking β a row becomes an immutable value object and nothing more.
π Beta-7 β shared limiter and breaker state, pool probe, reversible migrations
RateLimit\RedisLimiterStateStorage(NET-01) holds the token buckets behindLimiterStateStorageInterface: one Lua script refills and takes atomically on the Redis server clock, through the framework's Redis pool. Measured with 8 concurrent processes making 200 calls on a bucket of 50: exactly 50 admitted.CircuitBreaker\RedisCircuitStateStorage(NET-03) holds the circuits behindCircuitStateStorageInterface:acquire()andrecord()are each one Lua script (closed β open at the failure-rate threshold, open β half-open after the cool-down with bounded trial calls). Both storages fail asRateLimit\StateStorageException, which the limiter and the breaker turn into their failure mode.Health\ConnectionPoolHealthCheck(OPS-01) is the/readyzprobe for a pool: it leases one connection, asks itisAlive()and gives it back, so it costs one or two round trips and never opens a connection of its own. A pool that cannot lease is reported down with the reason, never thrown.- Ping freshness window (CARRY-01):
PDOConnectionPool'spingFreshnessMs(default0, a probe on every lease) skips theSELECT 1for a connection proven alive within that many milliseconds. - Reversible migrations (OPS-03):
MigrationRunner::rollback()andstatus(), below. DDL migrations work on MySQL and MariaDB again, whose DDL commits implicitly.
π¦ Installation
Requires PHP 8.5+ and ext-pdo. Depends only on waffle-commons/contracts (plus PSR + PHP core).
π§± Surface
| Class | Role |
|---|---|
Waffle\Commons\Data\Connection\PDOConnectionPool |
final pool of reusable PDO connections (ConnectionPoolInterface + ResettableInterface). Ping-before-dispense (SELECT 1), transparent reconnect, per-connection statement cache, reset() rolls back dangling transactions between requests. |
Waffle\Commons\Data\Query\Criteria |
Static factory for predicates: eq/neq/gt/gte/lt/lte/like/in/notIn. |
Waffle\Commons\Data\Query\Query |
Immutable, copy-on-write query AST (select / from / where / orderBy / limit / offset). Pure representation β knows nothing about any backend. |
Waffle\Commons\Data\Query\Operator / Direction |
enum operators (=, <>, >, β¦, IN, LIKE) and sort directions (ASC / DESC). |
Waffle\Commons\Data\Compiler\SQLCompiler / SQLWriteCompiler |
Compile a Query (reads) or a mapped entity row (INSERT/UPDATE/DELETE) into parameterized statements (? placeholders, injection-safe) for a chosen SQLDialect. |
Waffle\Commons\Data\Compiler\SQLDialect |
enum MySQL / MariaDB / SQLite / MSSQL / PostgreSQL / Oracle β identifier quoting + pagination grammar. |
Waffle\Commons\Data\Compiler\FirestoreCompiler |
Compiles a Query into a CompiledFirestoreQuery with path isolation; only equality is pushed server-side, ranges/ordering flag requiresInMemoryFilter. |
Waffle\Commons\Data\Compiler\FirestoreScope |
public(appId, collection) / private(appId, userId, collection) path scoping. |
Waffle\Commons\Data\Compiler\{Mongo,KeyValue,Cassandra,GraphQL}Compiler |
Per-backend SQR compilers: MongoDB filter documents, key-value GET/MGET plans, parameterised CQL, GraphQL query/mutation documents. |
Waffle\Commons\Data\Repository\β¦ |
Seven stateless WritableRepositoryInterface repositories β SQLRepository, FirestoreRepository (three auth guardrails), MongoRepository, CassandraRepository, KeyValueRepository, GraphQLRepository, JsonFileRepository β full CRUD through pure DataMapperInterface mappers. |
Waffle\Commons\Data\Driver\β¦ |
Live drivers: FirestoreRestClient, MongoDriverSession, RedisKeyValueClient, GraphQLExecutor (+ the injectable CQL port). Every backend failure is rethrown as a sanitized DatabaseException. |
Waffle\Commons\Data\Evaluation\InMemoryEvaluator |
Stateless fetch-then-filter evaluation (range/set/sort/offset) for backends with restricted server-side querying. |
Waffle\Commons\Data\Storage\JsonFileStore |
Atomic flat-file JSON store (read-modify-write under LOCK_EX). |
Waffle\Commons\Data\Hydrator\PropertyHookHydrator |
Maps a raw row onto an immutable DTO via its constructor; corrupt data is rejected by the DTO's PHP 8.5 set hooks as a ValidationExceptionInterface. |
Waffle\Commons\Data\Migration\MigrationRunner |
MigrationRunnerInterface β applies versioned *.sql files in order, tracked in waffle_migrations; each migration runs in its own transaction. rollback() and status() since Beta-7. |
Waffle\Commons\Data\RateLimit\RedisLimiterStateStorage |
LimiterStateStorageInterface on Redis: atomic token buckets shared by every worker (Beta-7, NET-01). |
Waffle\Commons\Data\CircuitBreaker\RedisCircuitStateStorage |
CircuitStateStorageInterface on Redis: shared circuit state for the HTTP client's breaker (Beta-7, NET-03). |
Waffle\Commons\Data\Health\ConnectionPoolHealthCheck |
HealthCheckInterface for a connection pool, for /readyz (Beta-7, OPS-01). |
Waffle\Commons\Data\Warmup\QueryWarmer |
DataWarmerInterface β pre-compiles named SQR trees into an atomic <?php return [β¦] artifact primed into OPcache (bin/waffle data:warmup, Beta-3). |
Waffle\Commons\Data\Exception\DatabaseException |
DatabaseExceptionInterface β wraps any backend failure, lifts the ANSI SQLSTATE from a PDOException. |
Waffle\Commons\Data\Exception\ValidationException |
ValidationExceptionInterface β a field-aware hydration/validation failure (surfaces as RFC 7807 422). |
π Quick start
Connection pool
Build a query, compile it for a backend
The same Query compiles to a Firestore payload via FirestoreCompiler with a FirestoreScope (public vs per-user path isolation).
Hydrate an immutable DTO
Run migrations (from the CLI)
MigrationRunner is wired into the console as bin/waffle db:migrate, db:status and db:rollback, and make:migration scaffolds a version (see the console component). A version V is the file V.sql; its optional V.down.sql reverts it. Programmatically:
A script that holds only comments is refused, never logged, and rollback() reads every targeted down script before it reverts anything.
π PHP 8.5 features used
final readonly classfor every value object (CompiledQuery,CompiledFirestoreQuery,Comparison,Order,FirestoreScope).- Property Hooks β DTOs validate inside their own
sethooks; the hydrator never sees invalid state. (A hooked DTO isfinal class+public private(set), since hooked properties cannot bereadonly.) - Asymmetric visibility (
public private(set)) on the immutableQuerybuilder. - First-class callable syntax (
$this->method(...)) in the compilers;enumwith methods (Operator::isSetOperator());never-returning rejection helpers; typed class constants.
π§ Architectural boundary (mago guard)
Production code under Waffle\Commons\Data may depend only on Waffle\Commons\Data\**, Waffle\Commons\Contracts\**, Psr\**, and @global + Psl\**. A forbidden use fails the build, not a reviewer β enforced by vendor/bin/mago guard (bundled into composer mago, zero baselines). Interfaces must be named *Interface, Exception\** classes must end in *Exception, and any Enum\** namespace may hold only enum declarations.
Contract-first, component-agnostic by construction: the data layer composes with the rest of the framework through waffle-commons/contracts, never directly through another component.
π§ͺ Testing
The full gate (composer mago && composer tests) runs format, lint, analyze, guard, and PHPUnit (β₯95% line coverage) with zero baselines.
π Documentation
Central framework docs (DiΓ‘taxis) for this component:
- Reference:
reference/data.md,reference/connection-pool.md - Explanation:
explanation/data-persistence.md,explanation/connection-pooling.md - How-to:
how-to/rate-limit-requests.md,how-to/make-outbound-calls-resilient.md,how-to/run-on-kubernetes.md - Full documentation tree: waffle-commons/documentation
π License
MIT β see LICENSE.md.
All versions of data with dependencies
ext-pdo Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
waffle-commons/contracts Version self.version