PHPackages                             seacommerce/mapper - 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. seacommerce/mapper

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

seacommerce/mapper
==================

Library for mapping data between types.

v0.2.13(7y ago)32.0k[1 PRs](https://github.com/Seacommerce/php-mapper/pulls)1MITPHPPHP &gt;=7.1CI failing

Since Feb 8Pushed 6y ago3 watchersCompare

[ Source](https://github.com/Seacommerce/php-mapper)[ Packagist](https://packagist.org/packages/seacommerce/mapper)[ Docs](https://seacommerce.nl)[ RSS](/packages/seacommerce-mapper/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (8)Versions (20)Used By (1)

[![Build Status](https://camo.githubusercontent.com/e1be405496c0d836a864d49752971ed3ebb6b24e8625c8f1aa83a652bd14ebb1/68747470733a2f2f7472617669732d63692e6f72672f536561636f6d6d657263652f7068702d6d61707065722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Seacommerce/php-mapper)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

Seacommerce Mapper
==================

[](#seacommerce-mapper)

A mapper for PHP to map data between objects that's optimized for performance and validation.

Features
--------

[](#features)

- Mapping from type to type.
- Automapping of matching properties, custom from-&gt;to, custom callbacks.
- Ignore properties.
- Validation (prevent unmapped properties).
- Compiled (using symfony/property-accessor for now, will add native compiler)

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

[](#installation)

```
composer require seacommerce/mapper
```

Why an automapper?
------------------

[](#why-an-automapper)

Having to deal with a big variety of data objects throughout the layers in your application, often requires a lot of copying of data between those data objects. Usually you find yourself calling a bunch of getters and setters in a row to go from one object to another and then again to go to the next layer (for example: Doctrine Entity &gt; Domain object &gt; Form/View and back again). This it typically where an automapper can save you a lot of manual coding by automatically mapping properties with a similar name for example.

For example, mapping between the following two data structures

```
class A
{
  private $id;
  private $name;
  private $desc;
  private $day;
  private $type;
  private $active;

  // Getters & Setters
}

class B
{
  private $id;
  private $name;
  private $type
  private $active

  // Getters & Setters
}
```

Could be reduced from

```
$b = new B();
$b->setId($a->getId());
$b->setName($a->getName());
$b->setType($a->getType());
$b->setIsActive($a->getIsActive());
```

To just

```
$b = $mapper->map($a, B::class);
```

Why another mapper?
-------------------

[](#why-another-mapper)

You might be wondering why this library exists since there are already (at least) three similar mapper libraries for PHP:

- [mark-gerarts/automapper-plus](https://github.com/mark-gerarts/automapper-plus)
- [janephp/automapper](https://github.com/janephp/janephp)
- [idr0id/papper](https://github.com/idr0id/Papper)

Although all of these libraries have their own strengths and features, none of them provide the features that I like to see in a mapper which are mainly validation and compilation (= performance).

### Validation

[](#validation)

Automatically mapping properties between objects removes a lot of manual work but does not make the process less prone to human errors. Typically, automappers map properties on a "best-effort" basis by only automatically mapping properties that exists on both sides. Non-matching properties on either side still need some manual configuration or will otherwise be simply ignored.

PHP does not have a language construct to point to classes and member names (like ` nameof` in C#) and therefore, configuring a mapping manually usualy involves refering to properties using their name in a string value. E.g.

```
$mapper
  ->forMember('id', Operation::mapFrom('prodcutId'))
  ->formember('dateCreated', Operation::ignore());
```

This is where bugs enter your system if there is no check on the existence of the properties or will at least cause you some headaches if you don't detect the typo in an early stage.

Validation is an early warning system that will reduce the headachs when dealing with mappings by checking the existence of the properties and the types ahead of time.

### Compilation

[](#compilation)

PHP provides multiple ways to read and write properties of an object:

- public fields,
- private fields with getter/setter methods
- array accessors
- magic methods \_\_get() and \_\_set()

An automapper would kinda lose it's value if we had to tell it what read/write method to use on the mapped objects so therefore, part of the "auto" in automapper includes some magic to figure out the right way to get/set the properties.

This magic comes with a performance price. Symfony provides the PropertyAccess component that makes it easier and faster (due to caching) but compiling the mapping to native php code with native performance would be better.

### mark-gerarts/automapper-plus

[](#mark-gerartsautomapper-plus)

Pro's

- Highly configurable.
- Actively maintained.
- Good documentation.
- Plays well with Symfony though a separate bundle (mark-gerarts/automapper-plus-bundle)

Con's

- No way to validate the mapping (not convention based).
- Not compiled (which isn't an issue if you use custom mappers but that kinda defeats the purpose of an auto mapper library).

### janephp/automapper

[](#janephpautomapper)

Pro's

- Compiled.
- Highly configurable.
- Plays well with Symphony (bundle included).

Con's

- Not very actively maintained.
- No way to validate the mapping.

### idr0id/papper

[](#idr0idpapper)

Pro's

- Mapping validation, yay!

Con's

- Not actively maintained, latest build fails.
- No documentation.
- No symfony bundle.

Examples
--------

[](#examples)

```
sdfsf
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.3% 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 ~5 days

Recently: every ~15 days

Total

16

Last Release

2571d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4d90ccd4014bf6aa16df793f5ee717f65dbd58d382706bfaf6d3d3aae7fb707?d=identicon)[sil](/maintainers/sil)

---

Top Contributors

[![smoelker](https://avatars.githubusercontent.com/u/5102879?v=4)](https://github.com/smoelker "smoelker (58 commits)")[![jdreesen](https://avatars.githubusercontent.com/u/424602?v=4)](https://github.com/jdreesen "jdreesen (1 commits)")

---

Tags

seacommerce

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/seacommerce-mapper/health.svg)

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

###  Alternatives

[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[winzou/state-machine

A very lightweight yet powerful PHP state machine

52113.7M18](/packages/winzou-state-machine)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[jolicode/automapper

JoliCode AutoMapper

213439.4k7](/packages/jolicode-automapper)

PHPackages © 2026

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