PHPackages                             kenny1911/doctrine-dbal-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. kenny1911/doctrine-dbal-hydrator

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

kenny1911/doctrine-dbal-hydrator
================================

Convert doctrine dbal query result to dto

0.1.1(8mo ago)0962↑66.7%[1 issues](https://github.com/Kenny1911/doctrine-dbal-hydrator/issues)MITPHPPHP ^8.1CI passing

Since Jul 23Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/Kenny1911/doctrine-dbal-hydrator)[ Packagist](https://packagist.org/packages/kenny1911/doctrine-dbal-hydrator)[ RSS](/packages/kenny1911-doctrine-dbal-hydrator/feed)WikiDiscussions 0.1.x Synced 1mo ago

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

Doctrine DBAL Hydrator
======================

[](#doctrine-dbal-hydrator)

\[ English | [Русский](./README-RU.md) \]

**`kenny1911/doctrine-dbal-hydrator`** is a PHP library for easy conversion of SQL query results (Doctrine DBAL) into typed DTOs (Data Transfer Objects) with support for custom mappings, enums, and Doctrine type handling.

🔥 Features
----------

[](#-features)

- **Flexible mapping** via PHP attributes (`#[Column]`)
- **Doctrine DBAL type support** (`Types::DATETIME_IMMUTABLE`, `Types::JSON`, etc.)
- **Automatic type conversion** (including enums)
- **Custom field name mapping** (`name: 'login' → $username`)
- **Seamless integration** with existing `Doctrine\DBAL\Connection`

📦 Installation
--------------

[](#-installation)

```
composer require kenny1911/doctrine-dbal-hydrator
```

🚀 Basic Usage
-------------

[](#-basic-usage)

### 1. Define a DTO

[](#1-define-a-dto)

```
use Doctrine\DBAL\Types\Types;
use Kenny1911\DoctrineDbalHydrator\Mapping\Attribute\Column;

final readonly class User
{
    public function __construct(
        #[Column]
        public string $id,
        #[Column(name: 'login')]  // Maps SQL column `login` to property `username`
        public string $username,
        #[Column]
        public Role $role,       // Enum support
        #[Column(type: Types::DATETIME_IMMUTABLE)]
        public \DateTimeImmutable $registeredAt,
    ) {}
}
```

### 2. Configure the Hydrator

[](#2-configure-the-hydrator)

```
use Kenny1911\DoctrineDbalHydrator\Hydrator;
use Kenny1911\DoctrineDbalHydrator\ObjectHydrator;
use Kenny1911\DoctrineDbalHydrator\Mapping\AttributeLoader;

/** @var \Doctrine\DBAL\Connection $conn */
$hydrator = new Hydrator(
    objectHydrator: ObjectHydrator::createByConnection($conn),
    loader: new AttributeLoader(),
);
```

### 3. Hydrate Data

[](#3-hydrate-data)

```
$data = $conn->fetchAssociative(
    query: 'SELECT * FROM users WHERE id = :id',
    params: [
        'id' => 'f4117ad3-5914-493d-90e1-4371832e82f4'
    ],
);

$user = $hydrator->hydrate(User::class, $data);
```

📌 Key Notes
-----------

[](#-key-notes)

- **No ORM required** — works directly with DBAL.
- **Immutability** — supports `readonly` DTOs.
- **Lightweight** — minimal dependencies.

📜 License
---------

[](#-license)

MIT

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance59

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

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.

###  Release Activity

Cadence

Every ~16 days

Total

3

Last Release

262d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c929378f19c1e2e6a9525debcf490ec49c991a3d1ac6133e3c9fa45cef184102?d=identicon)[Kenny1911](/maintainers/Kenny1911)

---

Top Contributors

[![Kenny1911](https://avatars.githubusercontent.com/u/25887351?v=4)](https://github.com/Kenny1911 "Kenny1911 (26 commits)")

---

Tags

convertdoctrinedbaltoolconverterobjecthydratordto

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kenny1911-doctrine-dbal-hydrator/health.svg)

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

###  Alternatives

[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4485.3M4](/packages/martin-georgiev-postgresql-for-doctrine)[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)[vlucas/spot2

Simple DataMapper built on top of Doctrine DBAL

605392.8k7](/packages/vlucas-spot2)[jsor/doctrine-postgis

Spatial and Geographic Data with PostGIS and Doctrine.

2191.6M1](/packages/jsor-doctrine-postgis)[larapack/doctrine-support

Better Doctrine Support with Laravel (Support for `enum`)

1752.3M55](/packages/larapack-doctrine-support)[friendsofdoctrine/dbal-clickhouse

Doctrine DBAL driver for ClickHouse

1141.2M1](/packages/friendsofdoctrine-dbal-clickhouse)

PHPackages © 2026

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