Skip to content
A symfony bundle for AutoMapper+
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
DependencyInjection Merge branch 'master' into feature-configuration-support Jul 13, 2019
Resources/config Merge branch 'master' into feature-configuration-support Jul 13, 2019
AutoMapperConfiguratorInterface.php Remove obsolete todo Nov 27, 2018
AutoMapperFactory.php Initial commit Oct 12, 2017
AutoMapperPlusBundle.php Initial commit Oct 12, 2017
LICENSE Create LICENSE (#1) Oct 12, 2017 Update the README Jul 13, 2019
composer.json Add support of symfony/flex (#6) Jul 30, 2018


A Symfony bundle for AutoMapper+. To see it in action, check out the demo app.

Table of Contents


The bundle is available on packagist:

$ composer require mark-gerarts/automapper-plus-bundle

Don't forget to register the bundle:

$bundles = [
    new AutoMapperPlus\AutoMapperPlusBundle\AutoMapperPlusBundle(),
    // ...


The automapper is available as a service: automapper_plus.mapper (or just type hint the AutoMapperPlus\AutoMapperInterface). You can register mapping configurations by creating a class that implements the AutoMapperConfiguratorInterface. This configurator class will have to define a configure method, that gets passed the configuration object:


namespace Demo;

use AutoMapperPlus\AutoMapperPlusBundle\AutoMapperConfiguratorInterface;
use AutoMapperPlus\Configuration\AutoMapperConfigInterface;
use Demo\Model\Employee\Employee;
use Demo\Model\Employee\EmployeeDto;

class AutoMapperConfig implements AutoMapperConfiguratorInterface
    public function configure(AutoMapperConfigInterface $config): void
        $config->registerMapping(Employee::class, EmployeeDto::class)
            ->forMember('fullName', function (Employee $source) {
                return $source->getFirstName() . ' ' . $source->getLastName();

        // And so on..

If you use autowiring, the configurators will be picked up automatically. Alternatively, you'll have to register the class as a service and tag it with automapper_plus.configurator. You can optionally add a priority parameter to the tag.

    class: Demo\AutoMapperConfig
    tags: ['automapper_plus.configurator']

You can register all your mappings in a single configurator class, or spread it across multiple classes. The choice is yours!


The options for the mapper can be configured. Create a config/packages/auto_mapper_plus.yaml file (or add to your config.yaml for older Symfony versions) with the following contents:

        create_unregistered_mappings: true

These options correspond with the ones of the Options object.

Full reference:

        # Only one option for now, more coming soon!
        create_unregistered_mappings: true

Using the configuration is completely optional, you can just set the options directly on the Options object in one of your configurators using $config->getOptions().

Further reading

For more info regarding the automapper itself, check out the project page.

You can’t perform that action at this time.