PHPackages                             wundii/data-mapper - 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. wundii/data-mapper

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

wundii/data-mapper
==================

Modern and fast object mapper for PHP 8.2+. Strict types. Converts CSV, JSON, XML, YAML, NEON, arrays, and objects to PHP objects.

1.5.0(1mo ago)57.5k↑33.3%15MITPHPPHP &gt;=8.2CI passing

Since Jul 29Pushed 2mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (16)Versions (48)Used By (5)

    ![wundii/data-mapper](https://raw.githubusercontent.com/wundii/data-mapper/refs/heads/main/assets/data-mapper-light.png)

[![PHP-Tests](https://camo.githubusercontent.com/70ed14cf01e4ebb9ac54845f9b98614e133fda70b6fb98b724c4a33de1a9cf46/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f77756e6469692f646174612d6d61707065722f636f64655f7175616c6974792e796d6c3f6272616e63683d6d61696e267374796c653d666f722d7468652d6261646765)](https://github.com/wundii/data-mapper/actions/workflows/code_quality.yml)[![PHPStan](https://camo.githubusercontent.com/e15d364c7c0af383f9784d4af8419c1fcd87fbb5b44f0d48e32ce327be958008/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e2e7376673f7374796c653d666f722d7468652d6261646765)](https://phpstan.org/)[![VERSION](https://camo.githubusercontent.com/c6fd519c7599298e8773a6407c06b7846dad3cb207a06f2acff2ef83ff0a75f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77756e6469692f646174612d6d61707065723f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/c6fd519c7599298e8773a6407c06b7846dad3cb207a06f2acff2ef83ff0a75f1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77756e6469692f646174612d6d61707065723f7374796c653d666f722d7468652d6261646765)[![PHP](https://camo.githubusercontent.com/4d7d0f71821c835e62acb0d3a74d12c81b24f9083a03ca5b7832ee272f63df36/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f77756e6469692f646174612d6d61707065723f7374796c653d666f722d7468652d6261646765)](https://www.php.net/)[![Rector](https://camo.githubusercontent.com/bd6dd5b52a4347de5aa8bd284d980f474d87da595a4c90d3300b9645c2bcbf7f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f526563746f722d382e322d626c75652e7376673f7374796c653d666f722d7468652d6261646765)](https://getrector.com)[![ECS](https://camo.githubusercontent.com/0f7ade62b75eb86dd60ed170f954932994f60c2b4678e94ad0c7a892d31d77b8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4543532d636865636b2d626c75652e7376673f7374796c653d666f722d7468652d6261646765)](https://tomasvotruba.com/blog/zen-config-in-ecs)[![PHPUnit](https://camo.githubusercontent.com/729283066c222d92f175922debb3efc12d423e06e2880f6cc08e9c8601764ff3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d2d556e69742d636865636b2d626c75652e7376673f7374796c653d666f722d7468652d6261646765)](https://phpunit.org)[![codecov](https://camo.githubusercontent.com/7f078591dcb82bbf81d3fc11bc17f4fb280b430e87ef8cb2de1ad29e61567f4f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f77756e6469692f646174612d6d61707065722f6d61696e3f746f6b656e3d544e43324d4d304d5753267374796c653d666f722d7468652d6261646765)](https://codecov.io/github/wundii/data-mapper)[![Downloads](https://camo.githubusercontent.com/d21ae889b63b12883f18d024a78237a95130bbf2c0acfc420ea505ac558edd88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77756e6469692f646174612d6d61707065722e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/wundii/data-mapper)

This library is an extremely fast and strictly typed object mapper built for modern PHP (8.2+). It seamlessly transforms data from formats like CSV, JSON, NEON, XML, YAML, arrays, and standard objects into well-structured PHP objects.

Ideal for developers who need reliable and efficient data mapping without sacrificing code quality or modern best practices.

Features
--------

[](#features)

- Mapping source data into objects
- Mapping source data with a list of elements into a list of objects
- Initialize object via constructor, properties or methods
- Map nested objects, arrays of objects
- Class mapping for interfaces or other classes
- Custom root element for starting with the source data
- Auto-casting for `float` types (eu to us decimal separator)
- Target alias via Attribute for properties and methods
- Automatic data sorting for constructor parameters

Supported Types
---------------

[](#supported-types)

- `null`
- `bool`|`?bool`
- `int`|`?int`
- `float`|`?float`
- `string`|`?string`
- `array`
    - `int[]`
    - `float[]`
    - `string[]`
    - `object[]`
- `object`|`?object`
- `enum`|`?enum`

Supported Formats
-----------------

[](#supported-formats)

optional formats are marked with an asterisk `*`

- `array`
- `csv`
- `json`
- `neon`\*
- `object`
    - `public property`
    - `public getters`
    - `method toArray()`
    - `attribute SourceData('...')`
- `xml`
- `yaml`\*

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

[](#installation)

Require the bundle and its dependencies with composer:

```
composer require wundii/data-mapper
```

### Installations for frameworks

[](#installations-for-frameworks)

- [Laravel Package](https://github.com/wundii/data-mapper-laravel-package)
- [Symfony Bundle](https://github.com/wundii/data-mapper-symfony-bundle)

Usage
-----

[](#usage)

### Minimal usage

[](#minimal-usage)

```
use Wundii\DataMapper\DataMapper;

/**
 * DataConfig default settings
 * - ApproachEnum::SETTER - will use the constructor to map the data
 * - AccessibleEnum::PUBLIC - will use only public properties/methods
 * - classMap = [] - will not map any classes
 */

$dataMapper = new DataMapper();

$testClass = $dataMapper->array($array, TestClass::class);
$testClass = $dataMapper->csv($csvFileOrContent, TestClass::class);
$testClass = $dataMapper->json($json, TestClass::class);
$testClass = $dataMapper->neon($neon, TestClass::class);
$testClass = $dataMapper->xml($xml, TestClass::class);
$testClass = $dataMapper->yaml($yaml, TestClass::class);
```

### Usage with custom configuration

[](#usage-with-custom-configuration)

```
use Wundii\DataMapper\DataConfig;
use Wundii\DataMapper\DataMapper;
use Wundii\DataMapper\Enum\ApproachEnum;

$dataConfig = new DataConfig(
        approachEnum: ApproachEnum::PROPERTY,
        classMap: [
            DateTimeInterface::class => DateTime::class,
        ],
    );
$dataMapper = new DataMapper($dataConfig);

$testClass = $dataMapper->array($array, TestClass::class);
$testClass = $dataMapper->csv($csvFileOrContent, TestClass::class);
$testClass = $dataMapper->json($json, TestClass::class);
$testClass = $dataMapper->neon($neon, TestClass::class);
$testClass = $dataMapper->xml($xml, TestClass::class);
$testClass = $dataMapper->yaml($yaml, TestClass::class);
```

###  Health Score

53

—

FairBetter than 97% of packages

Maintenance85

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 77.4% 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 ~15 days

Recently: every ~58 days

Total

40

Last Release

58d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/55cca8c4c5dafd979e8cfc4fc14747edc8e7abeda94074b5fa927b7687af55f9?d=identicon)[wundii](/maintainers/wundii)

---

Top Contributors

[![wundii](https://avatars.githubusercontent.com/u/58734845?v=4)](https://github.com/wundii "wundii (65 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (19 commits)")

---

Tags

deserializationhydrationjsonmapperneonobjectphpxmlyamljsonxmlarrayyamlcsvobjectneondeserializationmapperdatamapperdeserialize

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StyleECS

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[mledoze/countries

List of world countries in JSON, CSV, XML and YAML

6.2k699.7k6](/packages/mledoze-countries)[jasny/dotkey

Dot notation access for objects and arrays

14219.5k6](/packages/jasny-dotkey)[selective/transformer

A strictly typed array transformer with dot-access, fluent interface and filters.

3817.8k1](/packages/selective-transformer)[hiraku/xml_builder

Simple DSL for building XML

141.6k1](/packages/hiraku-xml-builder)

PHPackages © 2026

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