PHPackages                             api-skeletons/doctrine-orm-hydration-module - 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. api-skeletons/doctrine-orm-hydration-module

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

api-skeletons/doctrine-orm-hydration-module
===========================================

Doctrine ORM hydrators for Laminas

1.0.3(3y ago)05.5k5[1 issues](https://github.com/API-Skeletons/doctrine-orm-hydration-module/issues)MITPHPPHP ^7.4 || ~8.0.0

Since Mar 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/API-Skeletons/doctrine-orm-hydration-module)[ Packagist](https://packagist.org/packages/api-skeletons/doctrine-orm-hydration-module)[ RSS](/packages/api-skeletons-doctrine-orm-hydration-module/feed)WikiDiscussions master Synced 4w ago

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

[![Build Status](https://github.com/api-skeletons/doctrine-orm-hydration-module/workflows/Continuous%20Integration/badge.svg)](https://github.com/api-skeletons/doctrine-orm-hydration-module/actions)[![Code Coverage](https://camo.githubusercontent.com/8589e51cf9c6cbc7a248824c31a3b4213152002d4fa3c666ec5efe8586121aa9/68747470733a2f2f636f6465636f762e696f2f67682f6170692d736b656c65746f6e732f646f637472696e652d6f726d2d687964726174696f6e2d6d6f64756c652f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/api-skeletons/doctrine-orm-hydration-module/branch/master)[![Packagist](https://camo.githubusercontent.com/ec6b326f0a49e74bb0efff711079de06a47d11f7a51652447a30d6c7f727e28b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6170692d736b656c65746f6e732f646f637472696e652d6f726d2d687964726174696f6e2d6d6f64756c652e737667)](https://packagist.org/packages/api-skeletons/doctrine-orm-hydration-module)[![Downloads](https://camo.githubusercontent.com/ba6f1560087a3de4319953fce9b5cfba114faa0bf8df70a5fd278f832daf7f55/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6170692d736b656c65746f6e732f646f637472696e652d6f726d2d687964726174696f6e2d6d6f64756c652e737667)](https://packagist.org/packages/api-skeletons/doctrine-orm-hydration-module)

Doctrine Hydration Module
=========================

[](#doctrine-hydration-module)

This module provides a configurable way to create new doctrine hydrators. By using the configurable API, it is easy to create a custom hydrator for any use case you want.

The basic hydrator from the doctrine laminas hydrator is being used. It is possible to configure your own strategies for complex objects like referenced entities.

Supported features
==================

[](#supported-features)

- 1.0.x: A rewrite and editing of phpro/zf-doctrine-hydration-module requiring PHP 7.4+

Installation
============

[](#installation)

Add to composer.json
--------------------

[](#add-to-composerjson)

```
composer require api-skeletons/doctrine-orm-hydration-module

```

Add to application config
-------------------------

[](#add-to-application-config)

```
return array(
    'modules' => array(
        'ApiSkeletons\\DoctrineORMHydrationModule',
        // other libs...
    ),
    // Other config
);
```

### Hydrator configuration

[](#hydrator-configuration)

```
return array(
    'doctrine-hydrator' => array(
        'hydrator-manager-key' => array(
            'entity_class' => 'App\Entity\EntityClass',
            'object_manager' => 'doctrine.objectmanager.key.in.servicelocator',
            'by_value' => true,
            'naming_strategy' => 'custom.naming.strategy.key.in.servicemanager',
            'hydrator' => 'custom.hydrator.key.in.hydratormanager',
            'strategies' => array(
                'fieldname' => 'custom.strategy.key.in.servicemanager',
            ),
            'filters' => array(
                'custom_filter_name' => array(
                    'condition' => 'and', // optional, default is 'or'
                    'filter'    => 'custom.hydrator.filter.key.in.servicemanager',
                ),
            ),
        ),
    ),
);
```

**`entity_class`**

This property is used to specify the class of the entity that will be hydrated. You need to make sure that this entity is a mapped doctrine class.

**`object_manager`**

You can specify which object manager you want to use for the hydrator. The value is the key of the desired object manager in the service manager.

**`by_value`**

Specify if you want the hydrator to hydrate the entity by value or by reference.

**`naming_strategy`**

You can use a custom naming strategy for the hydrator. Specify the key of the naming strategy in the service manager. Note that this naming strategy needs to implement `NamingStrategyInterface`.

**`hydrator`**You can use a custom hydrator instead of the default `DoctrineObject` hydrator. Make sure this hydrator implements `HydratorInterface`.

**`strategies`**

It is possible to customize the hydration strategy of specific properties. Configure the property you want to customize with the key of the strategy in the service manager; Note that this strategy needs to implement `StrategyInterface`.

**`filters`**

This property can be used to apply filters on the Hydrator. You can specify a list of custom filters by defining the key of the filter in the service manager and the filter condition as described in the hydrator filter documentation. Note that this filter needs to implement `FilterInterface`.

From here on, you can get the hydrator by calling `get('hydrator-manager-key')` on the HydratorManager.

Custom Filters
==============

[](#custom-filters)

Custom filters allow you to fine-tune the results of the hydrator's `extract` functionality by determining which fields should be extracted.

To configure custom filters:

```
return array(
    'doctrine-hydrator' => array(
        'custom-hydrator' => array(
            // other config
            'filters' => array(
                'custom.filter.name' => array(
                    'condition' => 'and', //optional, default: FilterComposite::CONDITION_OR,
                    'filter' => 'custom.filter', // a name in the Service Manager
                ),
            ),
        ),
    ),
);
```

In this example configuration, the hydrator factory will retrieve `custom.filter` from the Service Manager and inject it as a filter into the hydrator. The filter must implement `Zend\Hydrator\Filter\FilterInterface`.

The service's `filter($fieldName)` function will be called by the hydrator during `extract` and the field name being extracted will be passed as an argument. The `filter()` function must return a truthy value: if `true` then the field will NOT be extracted.

Override hydrator:
==================

[](#override-hydrator)

If the standard DoctrineHydrator is not flexible enough, you can set a custom `hydrator`. This allows you to use an extended DoctrineHydrator or another existing hydrator, and configure it with this module.`.

```
return array(
    'doctrine-hydrator' => array(
        'custom-hydrator' => array(
            // other config
            'hydrator' => 'Zend\Hydrator\ArraySerializable'
        ),
    ),
);
```

Testing
=======

[](#testing)

This package is fully tested with Cs fixer and PhpUnit. The MongoDB tests require mongodb to be installed on your machine. You can skip these tests by adding a testsuite to the command:

```
# Php coding standards:
./vendor/bin/phpcs

# Phpunit:
./vendor/bin/phpunit
```

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 68.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 ~199 days

Total

4

Last Release

1284d ago

PHP version history (2 changes)1.0.0PHP ^7.4

1.0.3PHP ^7.4 || ~8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/49dd7d9dba889ac674b0da447d9c1e69d1128dc3ccbaef98ba83d6ee519fc2d6?d=identicon)[tom\_anderson](/maintainers/tom_anderson)

---

Top Contributors

[![veewee](https://avatars.githubusercontent.com/u/1618158?v=4)](https://github.com/veewee "veewee (139 commits)")[![TomHAnderson](https://avatars.githubusercontent.com/u/493920?v=4)](https://github.com/TomHAnderson "TomHAnderson (33 commits)")[![michalbundyra](https://avatars.githubusercontent.com/u/7423207?v=4)](https://github.com/michalbundyra "michalbundyra (12 commits)")[![boukeversteegh](https://avatars.githubusercontent.com/u/53926?v=4)](https://github.com/boukeversteegh "boukeversteegh (6 commits)")[![tasselchof](https://avatars.githubusercontent.com/u/7921861?v=4)](https://github.com/tasselchof "tasselchof (4 commits)")[![alcaeus](https://avatars.githubusercontent.com/u/383198?v=4)](https://github.com/alcaeus "alcaeus (2 commits)")[![phpboyscout](https://avatars.githubusercontent.com/u/175238?v=4)](https://github.com/phpboyscout "phpboyscout (1 commits)")[![tom-pryor](https://avatars.githubusercontent.com/u/1273529?v=4)](https://github.com/tom-pryor "tom-pryor (1 commits)")[![dorongutman](https://avatars.githubusercontent.com/u/719298?v=4)](https://github.com/dorongutman "dorongutman (1 commits)")[![Bilge](https://avatars.githubusercontent.com/u/470626?v=4)](https://github.com/Bilge "Bilge (1 commits)")[![fabiocarneiro](https://avatars.githubusercontent.com/u/1375034?v=4)](https://github.com/fabiocarneiro "fabiocarneiro (1 commits)")[![matwright](https://avatars.githubusercontent.com/u/4989280?v=4)](https://github.com/matwright "matwright (1 commits)")

---

Tags

laminasormdoctrinehydrator

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/api-skeletons-doctrine-orm-hydration-module/health.svg)

```
[![Health](https://phpackages.com/badges/api-skeletons-doctrine-orm-hydration-module/health.svg)](https://phpackages.com/packages/api-skeletons-doctrine-orm-hydration-module)
```

###  Alternatives

[doctrine/doctrine-orm-module

Laminas Module that provides Doctrine ORM functionality

4407.3M292](/packages/doctrine-doctrine-orm-module)[doctrine/doctrine-module

Laminas Module that provides Doctrine basic functionality required for ORM and ODM modules

3957.9M114](/packages/doctrine-doctrine-module)[doctrine/doctrine-mongo-odm-module

Laminas Module which provides Doctrine MongoDB ODM functionality

86676.6k35](/packages/doctrine-doctrine-mongo-odm-module)[doctrine/doctrine-laminas-hydrator

Doctrine hydrators for Laminas applications

362.8M17](/packages/doctrine-doctrine-laminas-hydrator)[zfc-datagrid/zfc-datagrid

Laminas Module that provides a datagrid for different datasources and output formats

1223.2k](/packages/zfc-datagrid-zfc-datagrid)

PHPackages © 2026

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