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.0(1mo ago)0611PolyForm-Noncommercial-1.0.0PHPPHP &gt;=8.2CI passing

Since Mar 25Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (7)Versions (6)Used By (1)

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: PolyForm Shield](https://camo.githubusercontent.com/d8fb46c82be4c5312bf3e372ac734dfdf6a8b328e9c2b2856af671adbb0600a5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d506f6c79466f726d253230536869656c642d626c75652e737667)](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 the **[Jardis Business Platform](https://jardis.io)** — Enterprise-grade PHP components for Domain-Driven Design

Three focused services for entity data operations: **Hydration** transforms raw database rows into typed PHP objects 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
- **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
- **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 [`jardisport/data`](https://github.com/jardisPort/data):

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

[](#documentation)

Full documentation, guides, and API reference:

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

License
-------

[](#license)

This package is licensed under the [PolyForm Shield License 1.0.0](LICENSE.md). Free for all use except building competing frameworks or developer tooling.

---

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

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance89

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

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 ~27 days

Total

2

Last Release

54d 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 (1 commits)")

---

Tags

snapshotdataidentityuuidentityhydrationnanoidchange-trackingHeadgentjardisfield-mapping

###  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

[ramsey/uuid

A PHP library for generating and working with universally unique identifiers (UUIDs).

12.6k700.2M3.3k](/packages/ramsey-uuid)[fakerphp/faker

Faker is a PHP library that generates fake data for you.

4.0k358.5M3.5k](/packages/fakerphp-faker)[dflydev/dot-access-data

Given a deep data structure, access data by dot notation.

720359.1M86](/packages/dflydev-dot-access-data)[symfony/polyfill-uuid

Symfony polyfill for uuid functions

690335.4M63](/packages/symfony-polyfill-uuid)[symfony/uid

Provides an object-oriented API to generate and represent UIDs

610280.0M754](/packages/symfony-uid)[riipandi/laravel-optikey

Use UUID, Ulid, or nanoid as optional or primary key in Laravel.

429.1k](/packages/riipandi-laravel-optikey)

PHPackages © 2026

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