PHPackages                             stasa87/auto-mapper-plus - 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. stasa87/auto-mapper-plus

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

stasa87/auto-mapper-plus
========================

An AutoMapper for PHP

2.0.2(7y ago)18461[1 PRs](https://github.com/smotlio87/automapper-plus/pulls)MITPHPPHP ^5.6 || ^7.2

Since Oct 8Pushed 5y ago1 watchersCompare

[ Source](https://github.com/smotlio87/automapper-plus)[ Packagist](https://packagist.org/packages/stasa87/auto-mapper-plus)[ RSS](/packages/stasa87-auto-mapper-plus/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (4)Versions (16)Used By (0)

AutoMapper+
===========

[](#automapper)

An automapper for PHP inspired by [.NET's automapper](https://github.com/AutoMapper/AutoMapper). Transfers data from one object to another, allowing custom mapping operations.

[![Build Status](https://camo.githubusercontent.com/538cd6a41fb816280d8a94fca8f3ccf835ba57ebf61dfaa347d4ce52fb6a693c/68747470733a2f2f7472617669732d63692e6f72672f6d61726b2d676572617274732f6175746f6d61707065722d706c75732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mark-gerarts/automapper-plus)

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Why?](#why)
- [Example usage](#example-usage)
- [In depth](#in-depth)
    - [Instantiating the AutoMapper](#instantiating-the-automapper)
    - [Using the AutoMapper](#using-the-automapper)
    - [Registering mappings](#registering-mappings)
        - [Custom callbacks](#custom-callbacks)
        - [Operations](#operations)
        - [Dealing with nested mappings](#dealing-with-nested-mappings)
        - [Handling object construction](#handling-object-construction)
        - [ReverseMap](#reversemap)
        - [Copying a mapping](#copying-a-mapping)
    - [Resolving property names](#resolving-property-names)
        - [Naming conventions](#naming-conventions)
        - [Explicitly state source property](#explicitly-state-source-property)
        - [Resolving names with a callback](#resolving-names-with-a-callback)
    - [The Options object](#the-options-object)
    - [Setting the options](#setting-the-options)
        - [For the AutoMapperConfig](#for-the-automapperconfig)
        - [For the mappings](#for-the-mappings)
    - [Mapping with stdClass](#mapping-with-stdclass)
    - [The concept of object crates](#the-concept-of-object-crates)
    - [Using a custom mapper](#using-a-custom-mapper)
    - [Misc](#misc)
- [Similar libraries](#similar-libraries)
- [See also](#see-also)
- [Roadmap](#roadmap)

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

[](#installation)

This library is available on [packagist](https://packagist.org/packages/mark-gerarts/auto-mapper-plus):

```
$ composer require "mark-gerarts/auto-mapper-plus"
```

If you're using Symfony, check out the [AutoMapper+ bundle](https://github.com/mark-gerarts/automapper-plus-bundle).

Why?
----

[](#why)

When you need to transfer data from one object to another, you'll have to write a lot of boilerplate code. For example when using view models, CommandBus commands, working with API responses, etc.

Automapper+ helps you by automatically transferring properties from one object to another, **including private ones**. By default, properties with the same name will be transferred. This can be overridden as you like.

Example usage
-------------

[](#example-usage)

Suppose you have a class Employee and an associated DTO.

```
