PHPackages                             ovrflo/jit-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. ovrflo/jit-hydrator

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

ovrflo/jit-hydrator
===================

A drop-in replacement for Doctrine ORM's default object hydrator capable of generating optimized hydration code for each query.

172.4kPHP

Since Feb 5Pushed 3mo ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

jit-hydrator
============

[](#jit-hydrator)

An (almost) drop-in replacement for Doctrine ORM's ObjectHydrator that generates custom hydration code depending on the query.

How it works
============

[](#how-it-works)

After it's registered as a hydrator in the EntityManager, the ORM will call it to hydrate queries at which point it either loads a cached query class, or it generates a new one. The generated class will then hydrate the result set.

How fast is it ?
================

[](#how-fast-is-it-)

In my fairly limited tests it was 50-80% faster than Doctrine ORM's ObjectHydrator. While for very simple queries (SELECTing &lt;10 columns without JOINs and only 1-2 rows) it might be a bit worse than ObjectHydrator, for bigger queries the performance will be drastically improved.

The table below shows a comparison of the hydrators for a query that returned 1,10,100..1000000 rows. Times are in milliseconds.

hydrator/rows1101001000100001000001000000scalar7.778.6818.83121.611181.2212616.69195576.84object6.227.3121.13137.161281.4812430.54134498.12array7.778.6618.73119.541137.9311265.48118089.68**jit**3.073.426.1233.05287.472686.8729322.57Installation
============

[](#installation)

### 1. Install package via composer

[](#1-install-package-via-composer)

```
composer require ovrflo/jit-hydrator
```

### 2. a. if using Symfony &gt;=4.0

[](#2-a-if-using-symfony-40)

```
# config/packages/doctrine.yaml, under doctrine.orm key, add
#doctrine:
#    orm:
        hydrators:
            jit: Ovrflo\JitHydrator\JitObjectHydrator
```

### 2. b. if using Doctrine ORM without a framework:

[](#2-b-if-using-doctrine-orm-without-a-framework)

```
$entityManager->getConfiguration()->addCustomHydrationMode('jit', \Ovrflo\JitHydrator\JitObjectHydrator::class);
```

### 3. Use it for a specific query

[](#3-use-it-for-a-specific-query)

```
        $query = $queryBuilder
            ->getQuery()
            ->setHint(Query::HINT_INCLUDE_META_COLUMNS, true)
            ->getResult('jit')
        ;
```

### Step 3 explained

[](#step-3-explained)

After you registered it, in order to use it you need 2 things. The most important one is `getResult('jit')` which tells Doctrine to use That hydrator. The second thing is `->setHint(Query::HINT_INCLUDE_META_COLUMNS, true)`. That's needed because otherwise Doctrine doesn't pass relation metadata to the Hydrator and it won't be able to work without it. Currently, only Doctrine's own ObjectHydrator receives this info without that Query Hint.

Status
======

[](#status)

While this is currently running in production on a relatively small app, I wouldn't dare calling it production-ready. I'm sure there are a few bugs to squash in there. In my limited testing it worked, significantly lowering response times and CPU usage. Less CPU time means happier users and also lower power bills. Sure, we don't tend to think about power bills, but if you're running a huge infrastructure that heavily uses Doctrine ORM, it might actually make a difference. If power usage isn't a concern, than at least consider having more CPU headroom for your codebase. I personally encourage any one that needs a faster hydrator to test it and maybe even send some issues and/or PRs 😊

Credits
=======

[](#credits)

I would like to thank @ocramius for his insightful blog post on [Doctrine ORM Hydration](https://ocramius.github.io/blog/doctrine-orm-optimization-hydration/), which gave me the idea to implement this. At the end of his blog post he suggested that performance may be improved by generating hydrator code.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance54

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/97dae30b9c9e4594cfe79d3fadb8f409ae9ec0d169af2628cd2475c464649080?d=identicon)[ovrflo](/maintainers/ovrflo)

---

Top Contributors

[![ovrflo](https://avatars.githubusercontent.com/u/4866936?v=4)](https://github.com/ovrflo "ovrflo (33 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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