PHPackages                             waffle-commons/data - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. waffle-commons/data

ActiveLibrary[Framework](/categories/framework)

waffle-commons/data
===================

Data component for Waffle framework.

0.1.0-beta5(2w ago)15[2 PRs](https://github.com/waffle-commons/data/pulls)1MITPHPPHP ^8.5CI passing

Since Jun 7Pushed 2w agoCompare

[ Source](https://github.com/waffle-commons/data)[ Packagist](https://packagist.org/packages/waffle-commons/data)[ RSS](/packages/waffle-commons-data/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (12)Versions (4)Used By (1)

[![Discord](https://camo.githubusercontent.com/b30f41baece56d71f7f496f7e39fd33a2a096221c66c648b350dd4fe14276c2e/68747470733a2f2f696d672e736869656c64732e696f2f646973636f72642f3735353238383030313539323033333339313f6c6f676f3d646973636f7264)](https://discord.gg/eKgywnfXr2)[![PHP Version Require](https://camo.githubusercontent.com/ad0a48fb287129b3f79042b6a43fa816c0b89d3ac6ea4eca6169f72eac777b17/687474703a2f2f706f7365722e707567782e6f72672f776166666c652d636f6d6d6f6e732f646174612f726571756972652f706870)](https://packagist.org/packages/waffle-commons/data)[![PHP CI](https://github.com/waffle-commons/data/actions/workflows/main.yml/badge.svg)](https://github.com/waffle-commons/data/actions/workflows/main.yml)[![codecov](https://camo.githubusercontent.com/fc02199f32fbe7770857284d5c46d5e8c0251b67cd9a40b298acdfe56e419a28/68747470733a2f2f636f6465636f762e696f2f67682f776166666c652d636f6d6d6f6e732f646174612f67726170682f62616467652e737667)](https://codecov.io/gh/waffle-commons/data)[![Latest Stable Version](https://camo.githubusercontent.com/f8ad2f5a8c2485295de62093c42e158800045a6cad016a608ec70e5fb9be7009/687474703a2f2f706f7365722e707567782e6f72672f776166666c652d636f6d6d6f6e732f646174612f76)](https://packagist.org/packages/waffle-commons/data)[![Latest Unstable Version](https://camo.githubusercontent.com/6ca69a23819f516da37d2bdeb2e1e795494e417df1ce499c6167b3ad0534aad6/687474703a2f2f706f7365722e707567782e6f72672f776166666c652d636f6d6d6f6e732f646174612f762f756e737461626c65)](https://packagist.org/packages/waffle-commons/data)[![Total Downloads](https://camo.githubusercontent.com/d706d12536e93d9f57ba1c93458493db74b8f7b88e90a3d0e96d74125ff3c228/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f776166666c652d636f6d6d6f6e732f646174612e737667)](https://packagist.org/packages/waffle-commons/data)[![Packagist License](https://camo.githubusercontent.com/12d2f578c887e0d113e5371b3bc0014a67d40bc32ae5db53e2884c38e1101398/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f776166666c652d636f6d6d6f6e732f64617461)](https://github.com/waffle-commons/data/blob/main/LICENSE.md)

Waffle Data Component
=====================

[](#waffle-data-component)

> **Release:** `0.1.0-beta5` | [`CHANGELOG.md`](./CHANGELOG.md)

The data &amp; 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.

📦 Installation
--------------

[](#-installation)

```
composer require waffle-commons/data
```

Requires PHP 8.5+ and `ext-pdo`. Depends only on `waffle-commons/contracts` (plus PSR + PHP core).

🧱 Surface
---------

[](#-surface)

ClassRole`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.`Waffle\Commons\Data\Warmup\QueryWarmer``DataWarmerInterface` — pre-compiles named SQR trees into an atomic `
