PHPackages                             shandy-dev/humus-doctrine-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. [Database &amp; ORM](/categories/database)
4. /
5. shandy-dev/humus-doctrine-hydrator

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

shandy-dev/humus-doctrine-hydrator
==================================

Humus Doctrine (recursive) Hydrator

1.1.0(12y ago)095MITPHPPHP &gt;=5.3.3

Since Sep 11Pushed 11y ago1 watchersCompare

[ Source](https://github.com/shandyDev/HumusDoctrineHydrator)[ Packagist](https://packagist.org/packages/shandy-dev/humus-doctrine-hydrator)[ Docs](https://github.com/prolic/HumusDoctrineHydrator)[ RSS](/packages/shandy-dev-humus-doctrine-hydrator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

### Humus Doctrine Hydrator

[](#humus-doctrine-hydrator)

[![Dependency Status](https://camo.githubusercontent.com/7a24ee26e102608a11c7b167838c00b17b8b6a5f588ef2e88b9d8e9b5d2b471f/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7061636b6167652f7068703a70726f6c69633a68756d75732d646f637472696e652d6879647261746f722f62616467652e706e67)](https://www.versioneye.com/package/php:prolic:humus-doctrine-hydrator)[![Total Downloads](https://camo.githubusercontent.com/22e7771b676a2e05bec2346c9d04eb61499fbb0018c347e6bca8706a49370c77/68747470733a2f2f706f7365722e707567782e6f72672f70726f6c69632f68756d75732d646f637472696e652d6879647261746f722f646f776e6c6f6164732e706e67)](https://packagist.org/packages/prolic/humus-doctrine-hydrator)[![Latest Stable Version](https://camo.githubusercontent.com/64bd348f9148ba5e85338f63eb2a65ad81c8188e087c37cbd37c71918e8b4c4b/68747470733a2f2f706f7365722e707567782e6f72672f70726f6c69632f68756d75732d646f637472696e652d6879647261746f722f762f737461626c652e706e67)](https://packagist.org/packages/prolic/humus-doctrine-hydrator)[![Latest Unstable Version](https://camo.githubusercontent.com/80b252ebc7daa12b2503123881573204c228114dde8c9626c824d74fcf699695/68747470733a2f2f706f7365722e707567782e6f72672f70726f6c69632f68756d75732d646f637472696e652d6879647261746f722f762f756e737461626c652e706e67)](https://packagist.org/packages/prolic/humus-doctrine-hydrator)

A Hydrator implementing Zend\\Stdlib\\Hydrator\\HydratorInterface, completely based on Doctrine\\Common

- can return cloned object
- let's you control what field should be extracted (recursively)
- can flat single keys

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

[](#requirements)

- [Zend Stdlib 2.2](https://github.com/zendframework/Component_ZendStdlib)
- [Doctrine\\Common &gt;=2.2](https://github.com/doctrine/common)
- [Doctrine\\ORM &gt;2.2](https://github.com/doctrine/doctrine2) or [Doctrine\\ODM\\MongoDB](https://github.com/doctrine/mongodb-odm)

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

[](#installation)

1. Add `"prolic/humus-doctrine-hydrator": "dev-master"` to your `composer.json`
2. Run `php composer.phar install`

Example
-------

[](#example)

Let's assume you want to hydrate an array to an object, and then you want to extract all it's internals

Example Class: "User", has relationships to his "Locale", "Language" and "Address". The address entity has also a relation to "Country".

```
$hydrator = new \Humus\Doctrine\Hydrator\Hydrator(
    $context->get('EntityManager'), // the entity manager
    true, // yes, we want a cloned object, not the original one
    array(
        'id',
        'name',
        'firstname',
        'fax',
        'email',
        'gender',
        'locale' => array(
            'name'
        ),
        'preferred_contact_type' => array(
            'id'
        ),
        'address' => array(
            'street',
            'zip',
            'city',
            'country' => array(
                'id',
                'name'
            ),
        ),
        'spoken_languages' => array(
            'id',
        ),
    ), // we describe, what should be returned by extract, otherwise it could be that
       // a) We dump the Unit of Work
       // b) We dump half of the database
    false //do not flat single keys
);

// we got some data
$data = array(
    'id' => 5,
);

// we get the cloned address object,
// just switch the clone argument in constructor to false, in order to get the real object back
$address = $hydrator->hydrate($data, new \Application\Entity\Contact());

$result = $hydrator->extract($address);
var_dump($result);

// output:
array(6) {
  ["id"]=>
  int(5)
  ["gender"]=>
  string(4) "male"
  ["name"]=>
  string(20) "Sascha-Oliver Prolic"
  ["locale"]=>
  array(1) {
    ["name"]=>
    string(10) "Deutsch DE"
  }
  ["address"]=>
  array(4) {
    ["street"]=>
    string(13) "Sample Street"
    ["zip"]=>
    string(5) "00000"
    ["city"]=>
    string(6) "Berlin"
    ["country"]=>
    array(2) {
      ["id"]=>
      int(1)
      ["name"]=>
      string(7) "Germany"
    }
  }
  ["spoken_languages"]=>
  array(1) {
    [0]=>
    array(1) {
      ["id"]=>
      int(1)
    }
  }
}

// Please note how the output changes (watch for locale) when you switch the "flatSingleKeys" flag to true
// in the constructor of the hydrator
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76% 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 ~298 days

Total

2

Last Release

4692d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a3d517fca6beada9002dedcf38cfd8b0e3df6f0dcfbd636a4c55c70da055bbb?d=identicon)[shandyDev](/maintainers/shandyDev)

---

Top Contributors

[![prolic](https://avatars.githubusercontent.com/u/394428?v=4)](https://github.com/prolic "prolic (19 commits)")[![mrVrAlex](https://avatars.githubusercontent.com/u/633883?v=4)](https://github.com/mrVrAlex "mrVrAlex (5 commits)")[![davidwindell](https://avatars.githubusercontent.com/u/1720090?v=4)](https://github.com/davidwindell "davidwindell (1 commits)")

---

Tags

doctrinehydratorzf2humus

### Embed Badge

![Health badge](/badges/shandy-dev-humus-doctrine-hydrator/health.svg)

```
[![Health](https://phpackages.com/badges/shandy-dev-humus-doctrine-hydrator/health.svg)](https://phpackages.com/packages/shandy-dev-humus-doctrine-hydrator)
```

###  Alternatives

[doctrine/doctrine-laminas-hydrator

Doctrine hydrators for Laminas applications

362.8M19](/packages/doctrine-doctrine-laminas-hydrator)[pmill/doctrine-array-hydrator

 An array to entity hydrator for Doctrine 2 entities

36482.9k3](/packages/pmill-doctrine-array-hydrator)

PHPackages © 2026

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