Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Easy Hydrator

Easy Hydrator Laravel Package

symplify/easy-hydrator

Symplify Easy Hydrator turns arrays into typed PHP objects via native attributes and constructor promotion. Map nested objects, arrays of objects, and custom keys without boilerplate or reflection code. A lightweight alternative to heavy serializers for clean DTO mapping in Laravel, Symfony, and pla...

View on GitHub
Deep Wiki
Context7

Hydrate arrays to objects easily with PHP 7.4 and constructor injection

Frequently asked questions about Easy Hydrator
What is symplify/easy-hydrator used for in a Laravel app?
It maps plain arrays into typed PHP objects using constructor injection and attribute-based key mapping, so you avoid hand-written factory code. In Laravel the sensible use case is at the boundary layer: API request DTOs, command payloads, read models, and integration adapters. It is not intended for Eloquent models, domain entities, or core business logic. Treat it as a small hydration adapter rather than an application-wide convention.
Is symplify/easy-hydrator still maintained?
The repository sits under Symplify's deprecated-packages namespace, which indicates it is abandoned or explicitly deprecated. There are no visible stars or dependents and no evidence of active issue triage or security response. Any production use would require internal ownership, pinning a commit, and a plan to fork or replace. For new Laravel work the default recommendation is to avoid it.
Does symplify/easy-hydrator work with Laravel 10 or 11 and PHP 8.2?
The package targets PHP 7.4 and constructor injection, and its compatibility with PHP 8.2+, Laravel 10/11, enums, readonly classes, and union types is unproven. Because it is framework-agnostic it can technically coexist with Laravel, but no tests confirm modern stack support. Validate against your actual PHP and Laravel matrix in a time-boxed spike before adopting it. If you must use it, pin the exact version and add contract tests for representative payloads.
How do I install symplify/easy-hydrator?
Install it with Composer as a normal dependency, for example composer require symplify/easy-hydrator, pinned to an exact version or commit. There is no Laravel service provider or auto-discovery step, so you instantiate the hydrator directly or bind it in the container yourself. Keep the install isolated to one module rather than spreading it across the codebase. Check that Composer resolution does not conflict with Laravel's dependency graph.
Can symplify/easy-hydrator map nested objects and arrays of objects?
Yes, mapping nested objects, arrays of objects, and custom keys is the package's core feature set. In practice, reflection and constructor-based hydration can fail opaquely when payload shapes drift, so test each nested shape explicitly. Add contract tests covering nested DTOs, collections, missing keys, and nulls. This is especially important for a deprecated package with no upstream bug-fix path.
How does symplify/easy-hydrator handle custom array keys?
It lets you map non-matching array keys to constructor parameters, typically via attributes on the DTO properties. That removes boilerplate for payloads whose field names differ from your object properties. Behavior for missing keys, nulls, and scalar coercion should be verified with contract tests rather than assumed. Document the expected payload shape next to each DTO.
What are good alternatives to symplify/easy-hydrator for Laravel?
For Laravel-first DTOs, spatie/laravel-data is the common choice because it integrates with validation, requests, and Eloquent. Symfony Serializer is a heavier but well-maintained option for framework-agnostic mapping. Plain constructor calls or hand-written factory methods remain the lowest-risk approach for small payloads. Compare candidates on maintenance, PHP 8.2+ support, and error behavior before deciding.
How do I use symplify/easy-hydrator safely in production?
Do not introduce it broadly; wrap it behind an internal Hydrator interface or application service so replacement is cheap. Pin the exact version or commit and record the deprecation status in your dependency register. Add contract tests for missing keys, nulls, nested objects, collections, scalar coercion, and constructor changes. Put a decision gate in place to adopt, fork, or replace, and keep a non-critical boundary as the only pilot area.
Does symplify/easy-hydrator integrate with Laravel validation or Eloquent?
No. It is a framework-agnostic array-to-object mapper and does not use Laravel validation, model casting, or container resolution. That means you still validate incoming data with FormRequests or validators before hydrating. It is also a poor fit for Eloquent models and domain entities, which should use Laravel-native construction. Restrict it to DTOs and read models at the boundary.
What is the performance of symplify/easy-hydrator compared to Laravel Data or Symfony Serializer?
There is no published benchmark specific to this package in the current context, so treat performance claims as unverified. Reflection- and constructor-based hydration is generally slower than hand-written factories but may be comparable to heavier serializers for small payloads. Measure it against spatie/laravel-data, Symfony Serializer, and explicit factories using your own representative payloads. Factor maintenance risk into the decision, since an abandoned package can cost more than any micro-benchmark difference.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager