PHPackages                             yeremi/schema-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. [API Development](/categories/api)
4. /
5. yeremi/schema-mapper

ActiveLibrary[API Development](/categories/api)

yeremi/schema-mapper
====================

A PHP library for mapping external API data to PHP objects using PHP 8 attributes.

v1.0.1(1y ago)034[1 PRs](https://github.com/yeremi/schema-mapper/pulls)MITPHPCI passing

Since Dec 25Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/yeremi/schema-mapper)[ Packagist](https://packagist.org/packages/yeremi/schema-mapper)[ GitHub Sponsors](https://github.com/yeremi)[ Patreon](https://www.patreon.com/YeremiLoli)[ RSS](/packages/yeremi-schema-mapper/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (5)Used By (0)

Schema Mapper
=============

[](#schema-mapper)

A PHP library for mapping external API data to PHP objects using PHP 8 attributes. This library helps you easily transform API responses into strongly-typed PHP objects with minimal boilerplate code.

---

Index
-----

[](#index)

1. [Requirements](#requirements)
2. [Installation](#installation)
3. [Basic Usage](#basic-usage)
4. [Features](#features)
5. [Error Handling](#error-handling)
6. [Examples](#examples)
7. [License](#license)
8. [Support](#support)

---

Requirements
------------

[](#requirements)

- PHP 8.0+

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

[](#installation)

Install the package via Composer:

```
composer require yeremi/schema-mapper
```

Basic Usage
-----------

[](#basic-usage)

1. Define your data class with attributes:

```
use Yeremi\SchemaMapper\Attributes\ApiSchema;

class User
{
    #[ApiSchema(key: 'first_name')]
    private string $firstName;

    #[ApiSchema(key: 'last_name')]
    private string $lastName;

    #[ApiSchema(key: 'email')]
    private string $email;

    // Getters
    public function getFirstName(): string
    {
        return $this->firstName;
    }

    public function getLastName(): string
    {
        return $this->lastName;
    }

    public function getEmail(): string
    {
        return $this->email;
    }
}
```

2. Use the normalizer to map your data:

```
use Yeremi\SchemaMapper\Normalizer\NormalizerInterface;

class MyUseCase {
    public function __construct(
        NormalizerInterface $normalizer
    ) {}

    public function fetchSomeData(){
        $response = [
            'first_name' => 'John',
            'last_name' => 'Doe',
            'email' => 'john@example.com'
        ];

        $user = $this->normalizer->normalize($response, User::class);
        echo $user->getFirstName(); // Outputs: John
    }
}
```

---

Features
--------

[](#features)

- Map API responses to PHP objects using attributes
- Support for nested objects
- Type validation
- Nullable properties support
- Dependency injection ready with interfaces

Error Handling
--------------

[](#error-handling)

The library throws specific exceptions:

- `TypeMismatchException`: When the data type doesn't match the property type
- `ReflectionException`: When there are issues with class reflection

Examples
--------

[](#examples)

For more examples and advanced use cases, refer to the [examples directory](./docs/examples) in the documentation.

License
-------

[](#license)

This project is open source and licensed under the MIT License - see the LICENSE file for details.

Support
-------

[](#support)

If you encounter any problems or have any questions, please [open an issue](https://github.com/yeremi/schema-mapper/issues).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance63

Regular maintenance activity

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 77.8% 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 ~12 days

Total

2

Last Release

488d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e70fd65b778a9e9dde98c0e377004ff4b8b06759c90cffb21425102627ad7df?d=identicon)[Yeremi](/maintainers/Yeremi)

---

Top Contributors

[![yeremi](https://avatars.githubusercontent.com/u/744184?v=4)](https://github.com/yeremi "yeremi (7 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (2 commits)")

---

Tags

normalizerapiattributes

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)[uderline/openapi-php-attributes

Automatically render your OpenApi 3 file describing your PHP API using attributes

2136.3k](/packages/uderline-openapi-php-attributes)[shahghasiadil/laravel-api-versioning

Elegant attribute-based API versioning solution for Laravel applications with built-in deprecation management and version inheritance

2913.6k](/packages/shahghasiadil-laravel-api-versioning)

PHPackages © 2026

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