jardissupport/data
Composer 安装命令:
composer require jardissupport/data
包简介
Entity hydration with change tracking, bidirectional field mapping, and identity generation (UUID v4/v5/v7, NanoID)
关键字:
README 文档
README
Part of Jardis — 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
- Two-Stage Hydration —
hydrate()for flat entities,hydrateAggregate()for nested aggregates with recursive object graphs - Programmatic Apply —
apply()sets properties likehydrate()but preserves the snapshot — changes are detected bygetChanges() - 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(), anddiff() - Value-Based Detection —
toArray()anddiff()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()andfromColumns()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
composer require jardissupport/data
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
All three services implement port interfaces from jardissupport/contract:
| Service | Interface | Purpose |
|---|---|---|
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 mapping |
Documentation
Full documentation, guides, and API reference:
docs.jardis.io/en/support/data
License
This package is licensed under the MIT License.
Jardis · Documentation · Headgent
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: https://docs.jardis.io/en/skills
jardissupport/data 适用场景与选型建议
jardissupport/data 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 106 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「data」 「snapshot」 「identity」 「uuid」 「entity」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jardissupport/data 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jardissupport/data 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jardissupport/data 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
PDF or Image generation from a Url or HTML page
Adds the EDTF data type to Wikibase
Captures website screenshot and converts website to PDF using Screenshot machine - online website screenshot generator and website to PDF converter.
Guzzle Snapshots Middleware
A simple library that allows transform any kind of data to native php data or whatever
统计信息
- 总下载量: 106
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 55
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-13