PHPackages                             meklis/array-to-object-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. meklis/array-to-object-mapper

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

meklis/array-to-object-mapper
=============================

Easy mapper array to nested objects

0.1(4y ago)069MITPHPPHP &gt;=7

Since Feb 20Pushed 2y ago1 watchersCompare

[ Source](https://github.com/meklis/array-to-object-mapper)[ Packagist](https://packagist.org/packages/meklis/array-to-object-mapper)[ RSS](/packages/meklis-array-to-object-mapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

Simple mapper to objects from array
===================================

[](#simple-mapper-to-objects-from-array)

### Features:

[](#features)

- Map nested structures
- Work with doc comments
- Detecting variable type from @var declaration
- Working with private and protected properties
- Strict mode allow check variable type (only for basic types)
- Working with map|array of objects
- Auto detect and map properties with camelCase and snake\_case

### Install

[](#install)

```
composer require meklis/array-to-object-mapper

```

### Usage example

[](#usage-example)

**See full example of usage in src/example**

ParentClass.php

```
class ParentClass
{
    /**
     * @var int
     */
    protected $id;

    /**
     * String with camelCases
     * @var string
     */
    protected $testString;

    /**
     * @var string
     */
    protected $variable_with_snake_case;

    /**
     * @var Child
     */
    protected $child;

    /**
     * @var Child[]
     */
    protected $childs;
}
```

Child.php

```
class Child
{
    /**
     * @var int
     */
    protected $id;

    /**
     * @var Child | null
     */
    protected ?Child $child;

    /**
     * @var array
     */
    protected $params = [];
}
```

classes.json

```
{
  "id": 144,
  "test_string": "This is test string",
  "variable_with_snake_case": "Variable with snake case",
  "child": {
    "id": 1,
    "child": null,
    "params": ["param1", "param2", "param3"]
  },
  "childs": [
    {
      "id": 1,
      "child": {
        "id": 6,
        "params": ["param1", "param2", "param3"]
      },
      "params": ["param1", "param2", "param3"]
    },
    {
      "id": 3,
      "child": null,
      "params": ["param1", "param2", "param3"]
    },
    {
      "id": 4,
      "child": null,
      "params": ["param1", "param2", "param3"]
    }
  ]
}
```

test.php - Testing file

```
require __DIR__ . '/../../vendor/autoload.php';

use \Meklis\ArrToObjectMapper\Mapper;
use \Meklis\ArrToObjectMapper\example\Classes\ParentClass;

$mapper = new Mapper();
$mapper->setStrict(true);
$data = json_decode(file_get_contents(__DIR__ . '/classes.json'),true);

$mapped = $mapper->map($data, ParentClass::class);

print_r($mapped);

// OUTPUT
/*
Meklis\ArrToObjectMapper\example\Classes\ParentClass Object
(
    [id:protected] => 144
    [testString:protected] => This is test string
    [variable_with_snake_case:protected] => Variable with snake case
    [child:protected] => Meklis\ArrToObjectMapper\example\Classes\Child Object
        (
            [id:protected] => 1
            [child:protected] =>
            [params:protected] => Array
                (
                    [0] => param1
                    [1] => param2
                    [2] => param3
                )

        )

    [childs:protected] => Array
        (
            [0] => Meklis\ArrToObjectMapper\example\Classes\Child Object
                (
                    [id:protected] => 1
                    [child:protected] => Meklis\ArrToObjectMapper\example\Classes\Child Object
                        (
                            [id:protected] => 6
                            [params:protected] => Array
                                (
                                    [0] => param1
                                    [1] => param2
                                    [2] => param3
                                )

                        )

                    [params:protected] => Array
                        (
                            [0] => param1
                            [1] => param2
                            [2] => param3
                        )

                )

            [1] => Meklis\ArrToObjectMapper\example\Classes\Child Object
                (
                    [id:protected] => 3
                    [child:protected] =>
                    [params:protected] => Array
                        (
                            [0] => param1
                            [1] => param2
                            [2] => param3
                        )

                )

            [2] => Meklis\ArrToObjectMapper\example\Classes\Child Object
                (
                    [id:protected] => 4
                    [child:protected] =>
                    [params:protected] => Array
                        (
                            [0] => param1
                            [1] => param2
                            [2] => param3
                        )

                )

        )

)
 */
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

1548d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/96e33529c633d65792035730b2f17d7c59e58672a97077ec684fd019d22a39d2?d=identicon)[meklis](/maintainers/meklis)

---

Top Contributors

[![meklis](https://avatars.githubusercontent.com/u/16430599?v=4)](https://github.com/meklis "meklis (13 commits)")

### Embed Badge

![Health badge](/badges/meklis-array-to-object-mapper/health.svg)

```
[![Health](https://phpackages.com/badges/meklis-array-to-object-mapper/health.svg)](https://phpackages.com/packages/meklis-array-to-object-mapper)
```

PHPackages © 2026

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