PHPackages                             lucleads/automap - 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. lucleads/automap

ActiveLibrary

lucleads/automap
================

Objects mapper library

v1.1.0(4y ago)021MITPHP

Since Oct 28Pushed 4y ago1 watchersCompare

[ Source](https://github.com/lucleads/Mapper)[ Packagist](https://packagist.org/packages/lucleads/automap)[ Docs](https://github.com/lucleads/Mapper)[ RSS](/packages/lucleads-automap/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)DependenciesVersions (5)Used By (0)

Mapper
======

[](#mapper)

[![PHP](https://camo.githubusercontent.com/9e388c159a4eca3d9e01b533cfc926ac4a00d33c17839abc570eb566677a17ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c414e47554147452d5048502d677265656e2e737667)](https://www.php.net/)

[![Github Follow](https://camo.githubusercontent.com/ce7d4ee32d0f93ce7d54daf67240ed4ac1c21cce6a32e868808ebef250774817/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f6c6c6f776572732f6c75636c656164733f7374796c653d736f6369616c)](https://github.com/lucleads)

Description
-----------

[](#description)

Library that automatically copies the attributes of an object to a Data Transfer Object.

This library works in a similar way to libraries like MapStruct in other languages such as Java.

DEPLOY
------

[](#deploy)

To deploy a sandbox of the library, modify de `.env` file located in the project root with your local settings, open a terminal in the root directory and execute the next command:

- `docker-compose up -d` *\[to build and deploy the docker container\]*

\***NOTE:** If you don't modify the `.env` file, the default values are:

- **Container name:** dto-mapper
- **Php version:** 8.0.10
- **Deployable port:** 81

HOW TO USE IT
-------------

[](#how-to-use-it)

In the path `/src/app/ExampleUseCase` you can find an example of how to implement a mapper.
The purpose of this library is to copy the values of the common fields of two objects.
For each pair of objects we have to create a mapper class (*Example:* `PersonOutputDtoMapper`).
That mapper class must extend from the abstract class `Mapper` and must contain in its constructor the entity which contains the fields values.
In that class, we can make a function (`map()`) that returns an instance of the class needed, for example a Data Transfer Object class.
The only content of this function should be a static call to its parent class method `mapAutomatically()` with the next parameters:

- **1st parameter:** The source object
- **2nd parameter:** The output object class expected
- **3rd parameter:** `self::class` *(The mapper class)*

To make our mapper find the source for the value of each field, there are three ways to do it:

- The value is in a public field with the same name in the source object and in the target object.
- The source object have a getter with the same name of the field of the target object.

    - *Example:*

        ```
        [
          "TargetObject",
          {
            "age": ?
          }
        ]
        ```

        ```
         [
            "SourceObject":
            {
               "lifetime": 40
            }
        ]
        ```

        ```
        class SourceObject
        {
            private int $lifetime;

            public function getAge(): int
            {
                return $this->lifetime;
            }
        }
        ```
- In the specific MapperClass, we can define the layers to find the value as a class Map attribute.

    - *Example:*

        ```
          [
            "TargetObject",
            {
              "age": ?
            }
          ]
        ```

        ```
         [
             "SourceObject":
             {
               "Age":
               {
                 "value": 40
               }
             }
         ]
        ```

        ```
        #[Map('Age.value', 'age')]
        class SourceObjectMapper
        {
            //logic
        }
        ```

    \***NOTE:** To define a map attributes, we must follow the next structure:
    `#[Map(`
    +
     `layers up the value separated by dots as string`
    +
    `,`
    +
    `field name in target object as string`
    +
    `]`

REQUIREMENTS
------------

[](#requirements)

Needed to deploy the proyect:

- [Docker engine](https://docs.docker.com/engine/install/)
- [Docker compose](https://docs.docker.com/compose/install/)

Tools used in docker build *(Don't need previous installation)*:

- [Composer](https://getcomposer.org/download/)
- [Xdebug](http://xdebug.org/)

\***NOTE:** The PHP version established in the `.env` file must be 8.0 or higher.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~27 days

Total

3

Last Release

1605d ago

Major Versions

v0.0.1-alpha → v1.0.02021-10-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/32d81db63487dc7a541f9cc82fddc16a3287d2effeee9a22dbc252a517aed379?d=identicon)[lucleads](/maintainers/lucleads)

---

Top Contributors

[![lucleads](https://avatars.githubusercontent.com/u/78828405?v=4)](https://github.com/lucleads "lucleads (20 commits)")

---

Tags

mapmapper

### Embed Badge

![Health badge](/badges/lucleads-automap/health.svg)

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

###  Alternatives

[doctrine/persistence

The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.

4.1k286.5M762](/packages/doctrine-persistence)[ramsey/collection

A PHP library for representing and manipulating collections.

1.2k486.0M69](/packages/ramsey-collection)[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k23.3M302](/packages/doctrine-mongodb-odm)[dasprid/enum

PHP 7.1 enum implementation

379146.0M11](/packages/dasprid-enum)[cuyz/valinor

Dependency free PHP library that helps to map any input into a strongly-typed structure.

1.5k9.2M108](/packages/cuyz-valinor)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49444.8M97](/packages/marc-mabe-php-enum)

PHPackages © 2026

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