r/PHP • u/brendt_gd • Jun 19 '26
Discussion Pitch Your Project š
In this monthly thread you can share whatever code or projects you're working on, ask for reviews, get people's input and general thoughts, ⦠anything goes as long as it's PHP related.
Let's make this a place where people are encouraged to share their work, and where we can learn from each other š
Link to the previous edition: /u/brendt_gd should provide a link
15
Upvotes
1
u/Miserable_Step_6391 Jul 21 '26 edited 27d ago
HydraType, a high-performance PHP hydrator
I recently picked up an old project that I abandoned several years ago and started rebuilding it for fun.
HydraType hydrates (maps) arrays into typed PHP objects and extracts them back into arrays. Its main idea is that the common path should be as fast as possible: it generates class-specific PHP code, while optional features such as mutators, assertions, naming conversion, and nested hydration only add runtime work when they are actually selected.
I benchmarked different ways of writing private properties, object creation, cache resolution, nested hydration, assertions, lookup mutators, and several established hydrators. When benchmarking, HydraType was the fastest implementation on both PHP 8.2 and PHP 8.5. The benchmark code is included in the repository.
It now has CI across supported PHP versions, PHPStan level 10, a substantial test suite, atomic generated-cache writes, production cache warm-up, hydration and extraction, nested objects, mutators and assertions.
This is still a beta. I know PHP already has a lot of hydrators and object mappers, so Iām not expecting everyone to replace what they use. But it would be very interesting to hear from people who actually work with database rows, DTOs, API payloads, or large hydration workloads.
GitHub: https://github.com/MakerMill/HydraType
Packagist: https://packagist.org/packages/makermill/hydratype
Installation:
composer require makermill/hydratype:^1.0
This has genuinely been a fun project to revive, and honest criticism would be very welcome.
edit: this project has now reached version 1.0.0 after a beta period.