PHPackages                             kassko/data-mapper-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. [Database &amp; ORM](/categories/database)
4. /
5. kassko/data-mapper-bundle

ActiveLibrary[Database &amp; ORM](/categories/database)

kassko/data-mapper-bundle
=========================

Integrates data-mapper in Symfony projects.

v1.0.2(4y ago)125.9k↓44.6%2[1 PRs](https://github.com/kassko/data-mapper-bundle/pulls)PHPPHP &gt;=5.5.0

Since Sep 14Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/kassko/data-mapper-bundle)[ Packagist](https://packagist.org/packages/kassko/data-mapper-bundle)[ RSS](/packages/kassko-data-mapper-bundle/feed)WikiDiscussions 1.0 Synced yesterday

READMEChangelog (10)Dependencies (6)Versions (61)Used By (0)

data-mapper-bundle
==================

[](#data-mapper-bundle)

[![Total Downloads](https://camo.githubusercontent.com/2c341f2981b98890f73bb591df2df9663f0a6cf892bd913aaab3a5fbd6755a09/68747470733a2f2f706f7365722e707567782e6f72672f6b6173736b6f2f646174612d6d61707065722d62756e646c652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/kassko/data-mapper-bundle)

This bundle integrates the data-mapper component into Symfony applications. Which is a mapper that provides a lot of features to represent some raw data as objects.

To know more about this component and how to use it, please read the [data-mapper documentation reference](https://github.com/kassko/data-mapper/blob/master/README.md).

Installation on Symfony 2
-------------------------

[](#installation-on-symfony-2)

**Note that:**

- The second version number is used when compatibility is broken
- The third for new feature
- The fourth for hotfix
- The first for new API or to go from pre-release to release (from 0 to 1)

Using a version in `0.14` is recommended. Versions in `0.15` are no longer maintained.

You can install the library with composer and here is a good requirement:

```
composer require kassko/data-mapper-bundle:"~0.14.4"
```

Register the bundle in `app/AppKernel.php`:

```
public function registerBundles()
{
    $bundles = array(
        new Kassko\Bundle\DataMapperBundle\KasskoDataMapperBundle(),
        new Kassko\Bundle\ClassResolverBundle\KasskoClassResolverBundle(),
    );
}
```

- [DataMapper service](#data-mapper-service)
- [Configuration reference](#config-ref)
- [Expression language integration](#expr-lang-integr)
    - [Expression language services](#expr-lang-services)
    - [Add a provider](#add-provider)
- [Object listener](#object-listener)
- [Custom loader](#custom-loader)

DataMapper service
------------------

[](#datamapper-service)

Get the service from your controller:

```
$this->get('kassko_data_mapper');
```

It represents a `Kassko\DataMapper\DataMapper` instance. To know more about this component and how to use it, please read the [data-mapper documentation reference](https://github.com/kassko/data-mapper/blob/master/README.md).

Configuration reference
-----------------------

[](#configuration-reference)

```
kassko_data_mapper:
    mapping:
        default_resource_type: annotations # Default is "annotations" or other type (1).
        default_resource_dir: # Optional.
        default_provider_method: # Optional.
        bundles: #optional section
            some_bundle:
                resource_type: annotations # Default is "annotations" or other type (1).
                resource_dir: # The resource dir of the given bundle.
                provider_method: ~ # Required. Default value is null.
                objects: # Optional section.
                    some_object:
                        resource_type: # Optional.
                        resource_path: # Optional. The resource directory with the resource name. If not defined, data-mapper fallback to resource_name and prepend to it resource_dir (or default_resource_dir). So if resource_path is not defined, case resource_name and resource_dir (or default_resource_dir) must be defined.
                        resource_name: # Optional. Only the resource name (so without the directory).
                        provider_method: # Optional. Override default_provider_method.
                        object_class: # Required (full qualified object class name).
    cache:
        metadata_cache: # Optional section
            class: # Optional.
            id: # Optional.
            life_time: # Default is 0
            is_shared: # Default is false
            adapter_class: # Default is "Kassko\Bundle\DataMapperBundle\Adapter\Cache\DoctrineCacheAdapter"
        result_cache: # Optional section and same as metadata_cache
    logger_service: # Optional. A logger service name. Il will be used for logging in data-mapper component.
```

(1) availables types are annotations, yaml, php, php\_file, yaml\_file. And maybe others, feel free to add custom mapping loaders.

Expression language integration
-------------------------------

[](#expression-language-integration)

### Expression language services

[](#expression-language-services)

### Add a provider

[](#add-a-provider)

```

```

With the code above, the container is available in your provider. You can use it:

```
use Kassko\DataMapper\Expression\ExpressionFunction;
use Kassko\DataMapper\Expression\ExpressionFunctionProviderInterface;

class ExpressionFunctionProvider implements ExpressionFunctionProviderInterface
{
    public function getFunctions()
    {
        return [
            new ExpressionFunction(
                'granted',
                function ($arg) {
                    return sprintf('container.get(%s)', $arg);
                },
                function (array $context, $value) {
                    return $context['container']->get($value);
                }
            ),
        ];
    }
}
```

Object listener
---------------

[](#object-listener)

The data-mapper needs to be able to retrieve an object listener from its full qualified class name. In order to do that, you have to register your object listener as a service and tag it with `kassko_data_mapper.listener`.

To know more about object listener, please read the [data-mapper documentation reference](https://github.com/kassko/data-mapper/blob/master/README.md).

Custom loader
-------------

[](#custom-loader)

DataMapper provide three formats for mapping: `annotations`, `yaml` and `php`. But you can use a custom mapping loader.

For more details about how to implement your custom loader, please read the [data-mapper documentation reference](https://github.com/kassko/data-mapper/blob/master/README.md).

### Use a service in a persistent object without injecting it

[](#use-a-service-in-a-persistent-object-without-injecting-it)

You need to add it in the registry. You can do that by this way.

Tag your service:

```

```

And then you can get your service from your persistent object:

```
trait LoggableTrait
{
    private function getLogger()
    {
        return Registry::getInstance()['logger'];
    }
}
```

```
class Person
{
    use LoggableTrait;

    private $id;
    private $name;
    private $address;

    public function getName()
    {
        if (! isset($this->address)) {
            $this->getLogger()->warning(sprintf('No address for %s', $this->name));
        }
    }
}
```

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance50

Moderate activity, may be stable

Popularity29

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 99% 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 ~81 days

Recently: every ~5 days

Total

52

Last Release

152d ago

Major Versions

v0.14.4.0 → v1.0.02021-12-03

v1.0.2 → v2.1.0-alpha2025-12-27

PHP version history (2 changes)0.1.0-alphaPHP &gt;=5.5.0

v2.1.0-alphaPHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fac4367e85288a508e3720645e35b3cbe119b93e06b2d8a382b0a375413a561?d=identicon)[kassko](/maintainers/kassko)

---

Top Contributors

[![kassko](https://avatars.githubusercontent.com/u/8608325?v=4)](https://github.com/kassko "kassko (96 commits)")[![ahsio](https://avatars.githubusercontent.com/u/1450211?v=4)](https://github.com/ahsio "ahsio (1 commits)")

---

Tags

datahydrateormaccessentitymapperextractrepositoryhydrationdao

### Embed Badge

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

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

###  Alternatives

[kassko/data-mapper

A mapper which gives a lot of features to representate some raw data like objects

1339.1k1](/packages/kassko-data-mapper)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[symfony/web-profiler-bundle

Provides a development tool that gives detailed information about the execution of any request

2.3k160.5M1.2k](/packages/symfony-web-profiler-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M733](/packages/sylius-sylius)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k9.0k1](/packages/kimai-kimai)

PHPackages © 2026

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