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

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

dealnews/data-mapper
====================

PHP Library for implementing the Data Mapper pattern

3.4.0(9mo ago)390112BSD-3-ClausePHPPHP ^8.2CI passing

Since Jul 5Pushed 2mo ago4 watchersCompare

[ Source](https://github.com/dealnews/data-mapper)[ Packagist](https://packagist.org/packages/dealnews/data-mapper)[ RSS](/packages/dealnews-data-mapper/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (5)Versions (17)Used By (2)

Data Mapper
===========

[](#data-mapper)

This library provides an interface and an abstract base class for creating data mapper objects.

It also provides a Repository class based on [dealnews/repository](https://github.com/dealnews/data-repository)which is tailored for use with Data Mapper classes.

The Data Mapper Pattern
-----------------------

[](#the-data-mapper-pattern)

From [Wikipedia](https://en.wikipedia.org/wiki/Data_mapper_pattern):

A Data Mapper is a Data Access Layer that performs bidirectional transfer of data between a persistent data store (often a relational database) and an in-memory data representation (the domain layer). The goal of the pattern is to keep the in-memory representation and the persistent data store independent of each other and the data mapper itself. The layer is composed of one or more mappers (or Data Access Objects), performing the data transfer. Mapper implementations vary in scope. Generic mappers will handle many different domain entity types, dedicated mappers will handle one or a few.

Why use the Data Mapper pattern?
--------------------------------

[](#why-use-the-data-mapper-pattern)

Consider a world where an application needs to move data from one storage system to another. With data mappers, the application does not need to understand the different storage layers.

```
$db_mapper = new \DB\Widget\Mapper();

// Load a Widget from a database
$widget = $db_mapper->load(1);

// Save the Widget to some external storage
// like a 3rd party API
$external_mapper = new \ExternalAPI\Widget\Mapper();
$widget = $external_mapper->save($widget);
```

Using the Repository
--------------------

[](#using-the-repository)

The Repository allows for an application to define in one place the classes that are mapped using mappers. This reduces duplicate code and allows for a greater level of abstraction within the application.

```
# Application\Repository.php
$repo = new \DealNews\DataMapper\Repository();
$repo->add_mapper("Widget", new \DB\Widget\Mapper());
```

```
# Application\SomeFile.php
require "Repository.php";

$widget = $repo->new("Widget");

$widget = $repo->save("Widget", $widget);
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance74

Regular maintenance activity

Popularity22

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94.1% 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 ~175 days

Recently: every ~73 days

Total

14

Last Release

276d ago

Major Versions

0.9.1 → 1.0.02020-04-23

1.1.0 → 2.0.02022-09-26

2.1.0 → 3.0.02024-02-12

PHP version history (4 changes)v0.9.0PHP &gt;=7.1.0

1.1.0PHP ^7.3

2.0.0PHP ^8.0

3.4.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/49531?v=4)[Brian Moon](/maintainers/brianlmoon)[@brianlmoon](https://github.com/brianlmoon)

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

---

Top Contributors

[![brianlmoon](https://avatars.githubusercontent.com/u/49531?v=4)](https://github.com/brianlmoon "brianlmoon (32 commits)")[![jearle-dealnews](https://avatars.githubusercontent.com/u/8784094?v=4)](https://github.com/jearle-dealnews "jearle-dealnews (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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