silpo-tech/mapper-bundle

Symfony mapper bundle, easy way to convert data.

Maintainers

Package info

github.com/silpo-tech/MapperBundle

pkg:composer/silpo-tech/mapper-bundle

Statistics

Installs: 2 579

Dependents: 4

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.1 2026-03-31 13:13 UTC

This package is auto-updated.

Last update: 2026-03-31 13:14:35 UTC


README

CI codecov License: MIT

Installation

The suggested installation method's via composer:

composer require silpo-tech/mapper-bundle

Setup

Register bundle in bundles.php file.

<?php

return [
    MapperBundle\MapperBundle::class => ['all' => true],
    AutoMapperPlus\AutoMapperPlusBundle\AutoMapperPlusBundle::class  => ['all' => true]
];

Configure mappings

  # this config only applies to the services created by this file
  _instanceof:
    AutoMapperPlus\AutoMapperPlusBundle\AutoMapperConfiguratorInterface:
      tags: ['automapper_plus.configurator']

  # and add to override implementation of AutoMapperConfig
  automapper_plus.configuration:
    class: MapperBundle\Configuration\AutoMapperConfig

Tests

composer test:run

AutoMapper Library Configuration

MapperBundle supports two automapper libraries:

Using AutoMapperPlus (Default)

No additional configuration needed. AutoMapperPlus is used by default.

Using JoliCode AutoMapper

  1. Install JoliCode AutoMapper:
composer require jolicode/automapper
  1. Register the JoliCode AutoMapper bundle in config/bundles.php:
<?php

return [
    MapperBundle\MapperBundle::class => ['all' => true],
    AutoMapper\Symfony\Bundle\AutoMapperBundle::class => ['all' => true],
];
  1. Configure MapperBundle to use JoliCode in config/packages/mapper.yaml:
mapper:
    automapper: jolicode

Feature Compatibility

Feature AutoMapperPlus JoliCode AutoMapper
Basic mapping
Collection mapping
Array to object
Object to array
PreLoader (usePreLoad)
Custom PropertyAccessors
Auto-configuration ✅ (native)

Note: Custom features like usePreLoad and custom PropertyAccessors (DoctrineProxyPropertyAccessor, MergePropertyAccessor) are only available when using AutoMapperPlus. JoliCode AutoMapper uses its own native features for similar functionality.