PHPackages                             agnostic-domain/mapping - 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. agnostic-domain/mapping

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

agnostic-domain/mapping
=======================

Simplify the hydration and extraction of agnostic domain objects

1.0(6y ago)35MITPHPPHP ^7.4CI failing

Since Mar 29Pushed 6y ago1 watchersCompare

[ Source](https://github.com/agnostic-domain/mapping)[ Packagist](https://packagist.org/packages/agnostic-domain/mapping)[ RSS](/packages/agnostic-domain-mapping/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependencies (5)Versions (5)Used By (0)

Agnostic Domain Mapping
=======================

[](#agnostic-domain-mapping)

 [ ![Agnostic Domain Mapping](https://camo.githubusercontent.com/7b7c36fc95e44457765e76361907a3babcfeafa3cf60067b755a32580b28da47/68747470733a2f2f692e696d6775722e636f6d2f305735596d30782e706e67) ](https://github.com/agnostic-domain/mapping)

 Simplify the hydration and extraction of agnostic domain objects

 [ ![Static analysis](https://camo.githubusercontent.com/4699b1bffaa7300d06acd30a9453eaa90013f7d2bfa578a5afb8748695e76a15/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374617469635f616e616c797369732d7068707374616e2d737563636573732e737667) ](https://github.com/phpstan/phpstan) [ ![Coding standard](https://camo.githubusercontent.com/1049d4a2633e962fba72072095377d216a713d4dc00c2b9e9a66ff7fdce6bcc6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64696e675f7374796c652d7073722d2d322d737563636573732e737667) ](https://www.php-fig.org/psr/psr-2/) [ ![License](https://camo.githubusercontent.com/68a5574ec00e3bf29ff811def290480d18c91e41e30f55447039c448c15d11b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d6d69742d737563636573732e737667) ](https://choosealicense.com/licenses/mit/)

Rationale
=========

[](#rationale)

According to DDD domain should be guarded against external constraints and let's say *agnostic*. Most ORMs impose constraints in order to work properly and even better ones aren't free from the object-relational impedance mismatch. Assuming that you are ruling out event sourcing and other alternatives (for whatever reason) and still want to use ORM while having clean domain you need to decouple them. This decoupling comes with the cost of mapping between two layers. The goal of this library isn't to eliminate this cost via magic and another set of framework constraints, but rather to **minimize**.

Key ideas
=========

[](#key-ideas)

- Hydration and extraction is done via reflection.
    - Domain constructors should reflect creating a new model, not data from which it's restored.
- Objects can be mapped in many to many relation.
    - Domain shouldn't be coupled with database's tables.

Installation
============

[](#installation)

```
composer require agnostic-domain/mapping
```

Getting started
===============

[](#getting-started)

### Mapping data object to domain object

[](#mapping-data-object-to-domain-object)

```
$article = adm(Article::class)
    ->id($data->id)
    ->title($data->title)($data);
```

### Reverse mapping domain object to data object

[](#reverse-mapping-domain-object-to-data-object)

```
$data = adm()->data($article);
$data->title = adm($article)->title();
```

[Documentation](doc/documentation.md)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

Total

4

Last Release

2238d ago

Major Versions

1.1.x-dev → 2.0.x-dev2020-03-29

### Community

Maintainers

![](https://www.gravatar.com/avatar/032b54c3470ba96499245c56dcd969beb02a64e89e06f32cc38f76e131a21aec?d=identicon)[daniel-iwaniec](/maintainers/daniel-iwaniec)

---

Top Contributors

[![daniel-iwaniec](https://avatars.githubusercontent.com/u/750044?v=4)](https://github.com/daniel-iwaniec "daniel-iwaniec (33 commits)")

---

Tags

agnosticdomainmappingphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/agnostic-domain-mapping/health.svg)

```
[![Health](https://phpackages.com/badges/agnostic-domain-mapping/health.svg)](https://phpackages.com/packages/agnostic-domain-mapping)
```

PHPackages © 2026

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