PHPackages                             makinacorpus/goat-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. makinacorpus/goat-hydrator

Abandoned → [makinacorpus/generated-hydrator-bundle](/?search=makinacorpus%2Fgenerated-hydrator-bundle)Library[Database &amp; ORM](/categories/database)

makinacorpus/goat-hydrator
==========================

Advanced configurable flat and hierarchical object hydrator

1.0.1(6y ago)02.1kGPL-2.0-or-laterPHPPHP ^5.6 || ^7.0CI failing

Since Nov 19Pushed 6y agoCompare

[ Source](https://github.com/pounard/goat-hydrator)[ Packagist](https://packagist.org/packages/makinacorpus/goat-hydrator)[ Docs](http://github.com/makinacorpus/php-hydrator)[ RSS](/packages/makinacorpus-goat-hydrator/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (9)Versions (9)Used By (0)

Goat hierachical hydrator
=========================

[](#goat-hierachical-hydrator)

Advanced object hydrator based upon supporting nested object hydration.

Optionnaly Ocramius/GeneratedHydrator can be seamlessly replaced by  for PHP 5.6 compatibility.

This package provides a Symfony 3.4 and 4.x compatible bundle.

Status
======

[](#status)

**Time has passed, and PHP 5.6 is not supported anywhere anymore, as a consequence****this package is not supported anymore**.

Please use [makinacorpus/generated-hydrator-bundle](https://github.com/makinacorpus/generated-hydrator-bundle)insetad.

This package may if necessary receive some updates, for bugfixes and security fixes.

Get started
===========

[](#get-started)

For efficiently hydrating objects, it may benefit from an offline preparation phase that introspects target object classes for later hydration. Using Symfony this preparation phase is done while compiling the container.

Test case scenario
------------------

[](#test-case-scenario)

Along this documentation, we will work on this scenario, we have three classes defined as such:

```
class A
{
    /**
     * @var B
     */
    private $b;

    public function getB(): ?B
    {
        return $this->b;
    }
}

class B
{
    private $bar;

    /**
     * @var C
     */
    private $c;

    public function getBar(): string
    {
        return $this->bar ?? '';
    }

    public function getC(): ?C
    {
        return $this->c;
    }
}

class C
{
    private $foo;

    public function getFoo(): string
    {
        return $this->foo ?? '';
    }
}
```

Standalone
----------

[](#standalone)

### Configuration

[](#configuration)

Simple configuration exemple, more documentation will come later:

```
$hydratorMap = new HydratorMap(\sys_get_temp_dir().'/hydrator/cache');

// Register the A class
$hydratorMap->addClassConfiguration(new ClassConfiguration(
    A::class,
    [
        'b' => B::class,
    ],
    [],
    HydratorInterface::CONSTRUCTOR_SKIP
));

// Register the B class
$hydratorMap->addClassConfiguration(new ClassConfiguration(
    C::class,
    [
        'c' => C::class,
    ],
    [],
    HydratorInterface::CONSTRUCTOR_SKIP
));
```

### Usage

[](#usage)

Usage is trivial:

```
$separator = '__';

$values = [
    'b__bar' => "Hello, "
    'b__c__foo' => "World !",
];

$hydrator = $hydratorMap->get(A::class);
$a = $hydrator->createAndHydrateInstance($values);
```

And now, calling `print $a->getB()->getBar() . $a->getB()->getC()->getFoo();` should display `Hello, World !`;

Symfony
-------

[](#symfony)

### Configuration

[](#configuration-1)

Add the bundle in your `bundles.php` file (there is no flex recipe yet):

```
return [
    // ...
    Goat\Hydrator\Bridge\Symfony\GoatHydratorBundle::class => ['all' => true],
];
```

Use the `goat_hydrator` configuration key:

```
goat_hydrator:

    # Blacklist prevents some classes from being registered as property to
    # hydrate within automatically found properties. These arethe properties
    # target types.
    blacklist:
        - DateTime
        - DateTimeImmutable
        - DateTimeInterface

    classes:

        # Class that are not registered here will not be hierachically
        # hydrated, you MUST register every class you'll need to hydrate.
        App\Domain\Foo:

            # Contructor type, can be "none", "normal" or "late"
            constructor: none

            # Each property defined here will be forcefully hydrated to the
            # given value, which should be an existing class.
            properties:
                role: App\Domain\Role

                # If you encounter issues due to property info component
                # finding invalid or too greedy types, you can disable a
                # property hydration by setting its value to null or false.
                some_other_property: false
```

### Usage

[](#usage-1)

Usage is the same as above, but for convenience you can inject the HydratorMap class into your controllers or services.

Behavior
--------

[](#behavior)

Each time you call `HydratorMap::get()` a new instance will be generated: if you iterate over, for example, an SQL result set, always use the same instance: there is caching happening each instance making it faster.

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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

Every ~67 days

Recently: every ~115 days

Total

8

Last Release

2260d ago

PHP version history (3 changes)1.0.0-alpha1PHP ^5.6 | ^7.0

1.0.0PHP ^5.6|^7.0

1.0.1PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/d21b98752b406528da88850922b1061f39bf72eb2126b413d5c12e275811a40b?d=identicon)[Makina Corpus](/maintainers/Makina%20Corpus)

---

Top Contributors

[![pounard](https://avatars.githubusercontent.com/u/341855?v=4)](https://github.com/pounard "pounard (18 commits)")

---

Tags

symfonydatabaseormhydrator

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[pomm-project/pomm-bundle

The Symfony2 bundle for Pomm2

81198.7k4](/packages/pomm-project-pomm-bundle)[pomm/pomm-bundle

The Symfony2 bundle for Postgresql Object Model Manager

3230.3k1](/packages/pomm-pomm-bundle)[friendsofsymfony1/doctrine1

PHP Database ORM for Symfony1. Do NOT use for new projects: please move to a newest Symfony release and Doctrine2

40581.8k](/packages/friendsofsymfony1-doctrine1)[goodwix/doctrine-json-odm

JSON Object-Document Mapping bundle for Symfony and Doctrine

2226.0k](/packages/goodwix-doctrine-json-odm)

PHPackages © 2026

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