PHPackages                             jardissupport/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jardissupport/data

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jardissupport/data
==================

Entity hydration with change tracking, bidirectional field mapping, and identity generation (UUID v4/v5/v7, NanoID)

v1.0.3(3w ago)0106MITPHPPHP &gt;=8.2CI passing

Since Jun 2Pushed 3w agoCompare

[ Source](https://github.com/jardisSupport/data)[ Packagist](https://packagist.org/packages/jardissupport/data)[ Docs](https://jardis.io)[ RSS](/packages/jardissupport-data/feed)WikiDiscussions main Synced yesterday

READMEChangelog (4)Dependencies (11)Versions (9)Used By (0)

Jardis Data
===========

[](#jardis-data)

[![Build Status](https://github.com/jardisSupport/data/actions/workflows/ci.yml/badge.svg)](https://github.com/jardisSupport/data/actions/workflows/ci.yml/badge.svg)[![License: MIT](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/a68b290dcc313d698dc138a1111aa83eee2f143605449d7e8b5416ea6f88558f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e322d3737374242342e737667)](https://www.php.net/)[![PHPStan Level](https://camo.githubusercontent.com/c51bda247654363d3e30bc352674dd761a9557803a14af0226eb411d6dc0006b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c253230382d627269676874677265656e2e737667)](phpstan.neon)[![PSR-12](https://camo.githubusercontent.com/34b10db0caa29bacd49bda5c437a8de95385f036f3230b31fa605326e18da22c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f64652532305374796c652d5053522d2d31322d626c75652e737667)](phpcs.xml)

> Part of **[Jardis](https://jardis.io)** — the Domain-Driven Design platform for PHP. You model your domain; Jardis generates the production-ready hexagonal code (DTOs, Command/Query handlers, repositories, persistence). This package is part of the open-source foundation that generated code runs on.

Three focused services for entity hydration and DTO mapping in PHP: **Hydration** transforms raw database rows into typed PHP objects — filling the entities and DTOs Jardis generates — with automatic change tracking. **FieldMapper** provides bidirectional array-key mapping between domain and database names. **Identity** generates unique identifiers (UUID v4/v5/v7, NanoID).

---

Features
--------

[](#features)

- **Two-Stage Hydration** — `hydrate()` for flat entities, `hydrateAggregate()` for nested aggregates with recursive object graphs
- **Programmatic Apply** — `apply()` sets properties like `hydrate()` but preserves the snapshot — changes are detected by `getChanges()`
- **Automatic Snapshots** — a snapshot is taken on every hydration call to establish the baseline for change detection. Snapshot keys are the original DB column names — used as source of truth for `toArray()`, `aggregateToArray()`, and `diff()`
- **Value-Based Detection** — `toArray()` and `diff()` automatically distinguish DB columns from relations by value type — no attributes required
- **Change Tracking** — field-level diff between current property values and the snapshot via `getChanges()`
- **Entity Cloning** — `clone()` for flat entity clone (DB columns), `cloneAggregate()` for deep clone including nested objects
- **Batch Loading** — `loadMultiple()` hydrates an array of database rows into an array of entities efficiently
- **Field Mapping** — `toColumns()` and `fromColumns()` rename array keys between domain and database names using an explicit map; `fromAggregate()` maps hierarchical arrays with per-entity mappings and filters unmapped keys
- **Identity Generation** — UUID v4 (random), v5 (deterministic), v7 (time-ordered with monotonic counter), and NanoID (compact, URL-safe)
- **PHP Attributes** — `#[Table]`, `#[Column]`, `#[PrimaryKey]`, `#[Aggregate]` for entity metadata
- **TypeCaster** — automatic DB-to-PHP type conversion (int, bool, float, DateTime, DateTimeImmutable, BackedEnum)

---

Installation
------------

[](#installation)

```
composer require jardissupport/data
```

Quick Start
-----------

[](#quick-start)

```
use JardisSupport\Data\Hydration;
use JardisSupport\Data\Identity;
use JardisSupport\Data\FieldMapper;

// --- Hydration ---
$hydration = new Hydration();

// Hydrate an entity from a database row
$user = new User();
$hydration->hydrate($user, [
    'id'         => 42,
    'first_name' => 'Jane',
    'last_name'  => 'Doe',
    'created_at' => '2024-06-01 10:00:00',
]);

// Apply programmatic changes (snapshot stays untouched)
$hydration->apply($user, ['first_name' => 'John']);

// Detect exactly what changed since hydration
$changes = $hydration->getChanges($user);
// ['first_name' => 'John']

// --- Identity ---
$identity = new Identity();

$id = $identity->generateUuid7();   // time-ordered, sortable
$id = $identity->generateUuid4();   // random
$id = $identity->generateUuid5($namespace, 'customer:12345');  // deterministic
$id = $identity->generateNanoId();  // compact, URL-safe (21 chars)

// --- FieldMapper ---
$mapper = new FieldMapper();

$map = ['customerName' => 'name', 'orderNumber' => 'order_number'];
$columns = $mapper->toColumns(['customerName' => 'Müller'], $map);
// ['name' => 'Müller']
$fields = $mapper->fromColumns(['name' => 'Müller'], $map);
// ['customerName' => 'Müller']
```

Interfaces
----------

[](#interfaces)

All three services implement port interfaces from `jardissupport/contract`:

ServiceInterfacePurpose`Hydration``JardisSupport\Contract\Data\HydrationInterface`Entity hydration, snapshots, change tracking`Identity``JardisSupport\Contract\Data\IdentityInterface`UUID v4/v5/v7, NanoID generation`FieldMapper``JardisSupport\Contract\Data\FieldMapperInterface`Bidirectional array-key mappingDocumentation
-------------

[](#documentation)

Full documentation, guides, and API reference:

**[docs.jardis.io/en/support/data](https://docs.jardis.io/en/support/data)**

License
-------

[](#license)

This package is licensed under the [MIT License](LICENSE.md).

---

**[Jardis](https://jardis.io)** · [Documentation](https://docs.jardis.io) · [Headgent](https://headgent.com)

AI-Assisted Development
-----------------------

[](#ai-assisted-development)

This package ships with a skill for Claude Code, Cursor, Continue, and Aider. Install it in your consuming project:

```
composer require --dev jardis/dev-skills
```

More details:

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance96

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Total

5

Last Release

21d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e07a1b668e9e01ee6d1b85de7b3be1c2513f68aae9494b2011d1592104d5daa0?d=identicon)[jardis](/maintainers/jardis)

---

Top Contributors

[![Headgent](https://avatars.githubusercontent.com/u/245725954?v=4)](https://github.com/Headgent "Headgent (7 commits)")

---

Tags

change-trackingdomain-driven-designentity-hydrationidentityjardisphpphpsnapshotdataidentityuuidentityDomain Driven Designhydrationhexagonal-architecturenanoidchange-trackingHeadgentjardisfield-mappingentity-hydration

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jardissupport-data/health.svg)

```
[![Health](https://phpackages.com/badges/jardissupport-data/health.svg)](https://phpackages.com/packages/jardissupport-data)
```

###  Alternatives

[dykyi-roman/awesome-claude-code

Claude Code extension for PHP: audits (architecture, DDD, security, performance, PSR, design patterns, Docker, CI/CD, tests, docs), 3-level code review, automated bug fix, generators (DDD, CQRS, GoF patterns, PSR, tests, documentation, Docker, CI/CD), code explanation, refactoring. 26 commands, 62 agents, 259 skills.

851.2k](/packages/dykyi-roman-awesome-claude-code)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
