PHPackages                             pfazzi/simplex-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. [Database &amp; ORM](/categories/database)
4. /
5. pfazzi/simplex-mapper

ActiveLibrary[Database &amp; ORM](/categories/database)

pfazzi/simplex-mapper
=====================

A simple mapping library

0.0.6(4y ago)43.9kMITPHPPHP &gt;=8.0

Since Jan 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/pfazzi/simplex-mapper)[ Packagist](https://packagist.org/packages/pfazzi/simplex-mapper)[ RSS](/packages/pfazzi-simplex-mapper/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (2)Versions (8)Used By (0)

SimplexMapper
=============

[](#simplexmapper)

A simple PHP library to transfer data from a source (object or array) to an object.

```
$dbData = [
    'username' => 'pfazzi',
    'emailAddress' => 'pfazzi@test.com',
    'isEnabled' => '1',
];

$mapper = new \Pfazzi\SimplexMapper\Mapper();

$user = $mapper->map(
    source: $dbData,
    target: User::class,
);
```

Are you looking for an easy way to convert an array to an object?
Do you want to map a DTO to a domain object?
Do you want to hydrate an object from an array?
Use SimplexMapper!

Features
--------

[](#features)

- Easy to use
- Zero configuration
- Zero dependencies
- Supports PHP 8 union types
- Supports nested objects
- Uses reflection, no need to modify your objects

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

[](#installation)

Install SimplexMapper with composer

```
composer require pfazzi/simplex-mapper
```

Usage
-----

[](#usage)

### Map

[](#map)

Maps the source data to a new instance of the target class

```
$mapper = new \Pfazzi\SimplexMapper\Mapper();

// From Array

$userEntity = $mapper->map(source: ['name' => 'patrick'], target: UserEntity::class);

// From stdClass

$rawData = new \stdClass();
$rawData->name = 'Patrick';

$userEntity = $mapper->map(source: $rawData, target: UserEntity::class);

// From anonymous class

$rawData = new class {
    public function __construct(private string $name = 'Patrick') {}
};

$userEntity = $mapper->map(source: $rawData, target: UserEntity::class);

// From object

$rawData = new UserDto('Patrick');

$userEntity = $mapper->map(source: $rawData, target: UserEntity::class);
```

### Hydrate

[](#hydrate)

Hydrates an object instance with data from the source:

```
$mapper = new \Pfazzi\SimplexMapper\Mapper();

$userEntity = $entityManager->find(UserEntity::class, 1);

// From Array

$mapper->hydrate(source: ['name' => 'patrick'], target: $userEntity);

// From stdClass

$rawData = new \stdClass();
$rawData->name = 'Patrick';

$mapper->map(source: $rawData, target: $userEntity);

// From anonymous class

$rawData = new class {
    public function __construct(private string $name = 'Patrick') {}
};

$mapper->map(source: $rawData, target: $userEntity);

// From object

$rawData = new UserDto('Patrick');

$mapper->map(source: $rawData, target: $userEntity);
```

Use Cases
---------

[](#use-cases)

### Map database data to read models

[](#map-database-data-to-read-models)

You want to read data from supplier table using Doctrine DBAL Connection and instantiate a Supplier read model:

```
class Supplier
{
    public function __construct(
        public int $id,
        public string $taxId,
        public bool $onConsignment,
    ) {
    }
}

$result = $connection->executeQuery( $taxId]);

$data = $result->fetchAssociative();
```

Without SimplexMapper you have to write mapping code, such as:

```
$readModel = new Supplier(
    (int) $data['id'],
    $data['taxId'],
    '1' == $data['isEnabled'],
);
```

With SimplexMapper all you need to write is just the following line:

```
$readModel = $this->mapper->map($data, Supplier::class);
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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 ~0 days

Total

6

Last Release

1584d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/97334b538a672a1433ff992a88e75f143f6bdcfb4f0a19be4dafd7ae4d748721?d=identicon)[pfazzi](/maintainers/pfazzi)

---

Top Contributors

[![pfazzi](https://avatars.githubusercontent.com/u/4489261?v=4)](https://github.com/pfazzi "pfazzi (23 commits)")

---

Tags

mappingormphpsql

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M543](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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