PHPackages                             martinezdelariva/hydrator - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. martinezdelariva/hydrator

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

martinezdelariva/hydrator
=========================

Hydrate and extract functions made simple. Ideally for flat or primitive data.

v1.0(8y ago)423.7k↓44.1%2MITPHPPHP &gt;=7.1

Since Nov 29Pushed 7y ago1 watchersCompare

[ Source](https://github.com/martinezdelariva/hydrator)[ Packagist](https://packagist.org/packages/martinezdelariva/hydrator)[ RSS](/packages/martinezdelariva-hydrator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (2)

[![Build Status](https://camo.githubusercontent.com/ae6cf734a1e39f791eab2a62d0077b9a78b5ee275370431ab1bcd2ccf7a07c42/68747470733a2f2f7472617669732d63692e6f72672f6d617274696e657a64656c61726976612f6879647261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/martinezdelariva/hydrator)

Hydrator
========

[](#hydrator)

Hydrate and extract functions made simple. Ideally for flat objects or primitive data.

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

[](#installation)

Install it using [Composer](https://getcomposer.org/)

```
composer require martinezdelariva/hydrator

```

Usage
-----

[](#usage)

Having the following class:

```
    class Person
    {
        private $name;
        private $age;
        private $hobbies = [];
        private $student = false;

        public function __construct(string $name, int $age, array $hobbies, bool $student)
        {
            $this->name     = $name;
            $this->age      = $age;
            $this->hobbies  = $hobbies;
            $this->student  = $student;
        }
    }
```

Extraction:

```
    use function Martinezdelariva\Hydrator\extract;

    $person = new Person("John", 29, ["soccer", "reading"], true);
    extract($person);

    // array (
    //   'name'    => 'John',
    //   'age'     => 29,
    //   'hobbies' => array (
    //       0 => 'soccer',
    //       1 => 'reading',
    //   ),
    //   'student' => true,
    // )
```

Hydration:

```
    use function Martinezdelariva\Hydrator\hydrate;

    $values = [
        "name"    => "Maria",
        "age"     => 30,
        "hobbies" => ["swimming", "coding"],
    ];
    $person = hydrate(Person::class, $values);

    // object(Person)#48 (4) {
    //   ["name":"Person":private] => string(5) "Maria"
    //   ["age":"Person":private]  => int(30)
    //   ["hobbies":Person":private]=>
    //       array(2) {
    //         [0]=>
    //         string(8) "swimming"
    //         [1]=>
    //         string(6) "coding"
    //       }
    //   ["student":"Person":private] => bool(false)
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3092d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1567749?v=4)[José Luis Martínez de la Riva Manzano](/maintainers/martinezdelariva)[@martinezdelariva](https://github.com/martinezdelariva)

---

Top Contributors

[![martinezdelariva](https://avatars.githubusercontent.com/u/1567749?v=4)](https://github.com/martinezdelariva "martinezdelariva (7 commits)")

---

Tags

hydrationhydratorserializationserializerserializeserializationhydratorhydration

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/martinezdelariva-hydrator/health.svg)

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

###  Alternatives

[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[laminas/laminas-hydrator

Serialize objects to arrays, and vice versa

12916.8M147](/packages/laminas-laminas-hydrator)

PHPackages © 2026

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