PHPackages                             mpalourdio/mpa-custom-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. mpalourdio/mpa-custom-doctrine-hydrator

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

mpalourdio/mpa-custom-doctrine-hydrator
=======================================

Module that helps you deal with dates for DoctrineModule &amp; ZF2 : filtering, hydration, Locale etc.

0.5.0(9y ago)47391MITPHPPHP ^5.6 || ^7.0

Since Apr 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mpalourdio/MpaCustomDoctrineHydrator)[ Packagist](https://packagist.org/packages/mpalourdio/mpa-custom-doctrine-hydrator)[ Docs](https://github.com/mpalourdio/MpaCustomDoctrineHydrator)[ RSS](/packages/mpalourdio-mpa-custom-doctrine-hydrator/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (12)Versions (13)Used By (0)

[![Build Status](https://camo.githubusercontent.com/7a26a18ed3a84732a908372be1a64dd9ab3dacfbb2620327aec035e2a7a3d404/68747470733a2f2f7472617669732d63692e6f72672f6d70616c6f757264696f2f4d7061437573746f6d446f637472696e654879647261746f722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/mpalourdio/MpaCustomDoctrineHydrator)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d74c34e3c38a5f841997fa5ed3f39ce06d9102bb6aba4db048070cf30e99ea64/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d70616c6f757264696f2f4d7061437573746f6d446f637472696e654879647261746f722f6261646765732f7175616c6974792d73636f72652e706e673f733d32633130396638623736356430353964346233336362316636313935656165303762326664623163)](https://scrutinizer-ci.com/g/mpalourdio/MpaCustomDoctrineHydrator/)[![Code Coverage](https://camo.githubusercontent.com/2a0162485bd8acea21fee8435645ba9ab087ccefa6751cf021054fa8c9f0b689/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d70616c6f757264696f2f4d7061437573746f6d446f637472696e654879647261746f722f6261646765732f636f7665726167652e706e673f733d62323439383733373134623363383566303864666364393330366264346336623963623139626130)](https://scrutinizer-ci.com/g/mpalourdio/MpaCustomDoctrineHydrator/)[![SensioLabsInsight](https://camo.githubusercontent.com/3cd26f518ad96e37e7140c3a1a7c3f7753172a5cdad6818c5ad94becd0f82a3c/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35386234306565652d653038372d343438392d623136392d3731343334623863323837392f6d696e692e706e67)](https://insight.sensiolabs.com/projects/58b40eee-e087-4489-b169-71434b8c2879)[![PHP 7.0+](https://camo.githubusercontent.com/661ec2b3805144b308f076cd3a7324daf1050bb3608c286ed3e0d49df1c3b03b/687474703a2f2f696d672e736869656c64732e696f2f62616467652f7068702d372e302b2d3838393242462e737667)](http://php.net)[![MIT Licensed](https://camo.githubusercontent.com/7bb7f9228d9997f09c313c4364647ef637486acd002aae26119a4e2cbf0ee808/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61646c6177736f6e2f766576616c2e737667)](LICENSE)

MpaCustomDoctrineHydrator
=========================

[](#mpacustomdoctrinehydrator)

Module that helps you deal with date/datetime/time for DoctrineORMModule &amp; ZF2 : filtering, hydration, Locale etc. Extends and replace the ZF2 Date Element, ZF2 DateTime Element, ZF2 Time Element to make them compliant 'out-of-the-box' with doctrine hydration.

Provides an extension of the DoctrineORMModule `AnnotationBuilder` and a factory for more ease. The `ElementAnnotationsListener` is overridden too in order to better suit needs regarding filtering and validation.

The filters and the elements can be used as standalone. Using the provided elements via the `FormElementManager` adds automatic conversion formats for date/date and time/time strings to `DateTime`. Automatic filtering and validation are provided regarding the date format (Y-m-d, Y-m-d H:i:s, H:i:s, etc.) that depends of the `Locale`. A placeholder is added to your form element too when rendered.

The hydrator service adds a strategy to every date column in your entity for extraction and hydration.

Requirements
============

[](#requirements)

PHP 7.0+ - Only Composer installation supported

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

[](#installation)

Run the command below to install via Composer

```
composer require mpalourdio/mpa-custom-doctrine-hydrator
```

Add "MpaCustomDoctrineHydrator" to your **modules list** in **application.config.php**

Configuration
=============

[](#configuration)

Copy **mpacustomdoctrinehydrator.config.global.php.dist** in your **autoload folder** and rename it by removing the .dist extension.

Add your own date / time formats (if needed) that are compliant with php `DateTime`

see

Usage (the easy and lazy way)
=============================

[](#usage-the-easy-and-lazy-way)

Create your forms with the provided annotation builder.

```
$builder       = new \MpaCustomDoctrineHydrator\Form\Annotation\AnnotationBuilder($this->entityManager, $this->formElementManager);
$form = $builder->createForm('Application\Entity\Myentity');
```

Or with the factory

```
$form = $this->sm->get('annotationbuilder')->createForm('Application\Entity\Myentity');
```

Then, hydrate your form

```
$hydrator = $this->sm->get('hydrator')->setEntity('Application\Entity\Myentity');
$form->setHydrator($hydrator);
```

You're done! Date/Date &amp; Time/ Time colums will be hydrated/extracted, filtered and validated automatically, without providing anything else in your entities. Your form elements will be rendered with a placeholder.

Usage (the hard and decoupled way)
==================================

[](#usage-the-hard-and-decoupled-way)

```
$hydrator = $this->sm->get('hydrator')->setEntity('Application\Entity\Myentity');
$form->setHydrator($hydrator);
```

In your forms classes, when not using the `FormElementManager` :

```
$this->add(
            [
                'name'       => 'mydate',
                'type'       => 'MpaCustomDoctrineHydrator\Form\Element\Date',
                'attributes' => [
                    'id'    => 'mydate',
                ],
                'options'    => [
                    'label'  => 'My date',
                    'format' => 'd/m/Y' // format needed
                ],
            ]
        );
```

If you pull your forms from the `FEM`, just grab the element as a `'Date'` or `'Zend\Form\Element\Date'`. The format option is not needed here, config will be pulled from service config.

```
$this->add(
            [
                'name'       => 'mydate',
                'type'       => 'Date',
                'attributes' => [
                    'id'    => 'mydate',
                ],
                'options'    => [
                    'label'  => 'My date',
                ],
            ]
        );
```

You can too use the filter as standalone on other form elements with custom formats, if needed. For this, use the filter FQCN.

If you use the filter shortname (`DateToDateTime `), the config will be pulled from the service config (ie. The options array will be ignored).

```
public function getInputFilterSpecification()
{
        $filters = [
            'otherdate' => [
                'filters' => [
                    [
                        'name' => 'MpaCustomDoctrineHydrator\Filter\DateToDateTime',
                        'options' => [
                            'format' => 'd/m/Y' ('date_format' key is also accepted)
                        ]
                    ],
                ],
            ],
        ];
        return $filters;
}
```

or simply

```
public function getInputFilterSpecification()
{
        $filters = [
            'otherdate' => [
                'filters' => [
                    [
                        'name' => 'DateToDateTime',
                    ], // no options needed here, would be ignored anyway
                ],
            ],
        ];
        return $filters;
}
```

/!\\ If you don't create your fieldsets/forms via the `FormElementManager`, you must manually inject the SL so the `Date` element can fetch the configuration

```
$this->getFormFactory()->getFormElementManager()->setServiceLocator($this->sm);
```

/!\\ Tip : To use the `'DateToDateTime'` filter short name in a form grabbed without the `FEM`, you must do the following :

```
$plugins = $this->sm ->get('FilterManager');
$chain   = new FilterChain;
$chain->setPluginManager($plugins);
$myForm->getFormFactory()->getInputFilterFactory()->setDefaultFilterChain($chain);
```

You can use the provided strategy as standalone with your hydrators too. **Date Time and Time handling work the same way as the example above**, with only few changes, like the 'format' keys names.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

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

Every ~91 days

Recently: every ~223 days

Total

11

Last Release

3481d ago

PHP version history (2 changes)0.1.0PHP &gt;=5.5

0.5.0PHP ^5.6 || ^7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4fdbda774ff506689d09a6030ea897b292188db54d9edb53af8289d8313e9da8?d=identicon)[mpalourdio](/maintainers/mpalourdio)

---

Top Contributors

[![mpalourdio](https://avatars.githubusercontent.com/u/5034671?v=4)](https://github.com/mpalourdio "mpalourdio (191 commits)")

---

Tags

datedoctrine2doctrineormmodulehydrationzf2zf2-moduleormdoctrinemodulezf2

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mpalourdio-mpa-custom-doctrine-hydrator/health.svg)

```
[![Health](https://phpackages.com/badges/mpalourdio-mpa-custom-doctrine-hydrator/health.svg)](https://phpackages.com/packages/mpalourdio-mpa-custom-doctrine-hydrator)
```

###  Alternatives

[hounddog/doctrine-data-fixture-module

Zend Framework 2 Module that provides Doctrine Data-Fixture functionality

37335.4k9](/packages/hounddog-doctrine-data-fixture-module)[mamuz/mamuz-blog

Provides blog feature for ZF2 with Doctrine

101.1k1](/packages/mamuz-mamuz-blog)

PHPackages © 2026

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