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

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

wundii/data-mapper-symfony-bundle
=================================

A Symfony integration for 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.1.0(6mo ago)21.5kMITPHPPHP &gt;=8.2CI passing

Since Jun 8Pushed 2w agoCompare

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

READMEChangelog (10)Dependencies (14)Versions (28)Used By (0)

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

[![PHP-Tests](https://camo.githubusercontent.com/5e2706e094ecd9523b6a245d8551194bd2ecfb94b82e1a2afe65e7cc465bdc92/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f77756e6469692f646174612d6d61707065722d73796d666f6e792d62756e646c652f636f64655f7175616c6974792e796d6c3f6272616e63683d6d61696e267374796c653d666f722d7468652d6261646765)](https://github.com/wundii/data-mapper-symfony-bundle/actions/workflows/code_quality.yml)[![PHPStan](https://camo.githubusercontent.com/e15d364c7c0af383f9784d4af8419c1fcd87fbb5b44f0d48e32ce327be958008/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e2e7376673f7374796c653d666f722d7468652d6261646765)](https://phpstan.org/)[![VERSION](https://camo.githubusercontent.com/60fde37ab7a5da823717b60f9c3826bd46b24e7914cf97d4d0159e920d3ad287/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77756e6469692f646174612d6d61707065722d73796d666f6e792d62756e646c653f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/60fde37ab7a5da823717b60f9c3826bd46b24e7914cf97d4d0159e920d3ad287/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77756e6469692f646174612d6d61707065722d73796d666f6e792d62756e646c653f7374796c653d666f722d7468652d6261646765)[![PHP](https://camo.githubusercontent.com/a4dd6d6164981cdf14121e3944837fdc1975e5a82d36288d6532a1d0fb9d1c6c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f77756e6469692f646174612d6d61707065722d73796d666f6e792d62756e646c653f7374796c653d666f722d7468652d6261646765)](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/a9f001c431415abef9a412007f39010fce850188bf7e9ec07bb84807c53ce3bf/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f77756e6469692f646174612d6d61707065722d73796d666f6e792d62756e646c652f6d61696e3f746f6b656e3d5636314f4c4855385833267374796c653d666f722d7468652d6261646765)](https://codecov.io/github/wundii/data-mapper-symfony-bundle)[![Downloads](https://camo.githubusercontent.com/4d9e48fa868b1dae07a6956f082cfadebf8f2f1a0cbe59a7b03e13336cd33b3d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77756e6469692f646174612d6d61707065722d73796d666f6e792d62756e646c652e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/wundii/data-mapper-symfony-bundle)

A Symfony integration for [wundii/data-mapper](https://github.com/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, array, 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-symfony-bundle
```

Include the bundle in your `bundles.php`:

```
return [
    // ...
    Wundii\DataMapper\SymfonyBundle\DataMapperBundle::class => ['all' => true],
];
```

Create a Symfony configuration file `config/packages/data_mapper.yaml` with the command:

```
bin/console data-mapper:default-config
```

Configuration File
------------------

[](#configuration-file)

The following setting options are available

```
data_mapper:
    data_config:
        approach: 'CONSTRUCTOR|PROPERTY|SETTER' # ApproachEnum::SETTER
        accessible: 'PRIVATE|PUBLIC' # AccessibleEnum::PUBLIC
        class_map:
          InterfaceOrClassName: 'ClassName', # Class mapping for interfaces or other classes
          ...: ...
```

Use as Symfony DataMapper version
---------------------------------

[](#use-as-symfony-datamapper-version)

```
