netmex / hydrator-bundle
Package info
github.com/netmexmedia/HydratorBundle
Type:symfony-bundle
pkg:composer/netmex/hydrator-bundle
Requires
- symfony/framework-bundle: ^7.2
- symfony/serializer-pack: ^1.3
- symfony/validator: ^7.2
Requires (Dev)
- phpunit/phpunit: ^12.1
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-28 10:06:44 UTC
README
Netmex HydratorBundle is a Symfony bundle for mapping, transforming, and validating input data into PHP objects and data transfer objects (DTOs).
Define reusable mapper definitions to control how input fields are processed, how values are transformed, and how validation constraints are applied. The bundle also supports nested mappings, recursive hydration, and mapping collections of input data.
Features
- Reusable mapper definitions
- Custom field transformers
- Symfony Validator constraints
- Nested and recursive hydration
- Collection hydration
- Hydration of existing objects
- Configurable mapping options
- Integration with Symfony's service container
Installation
composer require netmex/hydrator-bundle
See the installation guide for configuration details.
Quick start
Create a mapper definition by implementing MapperDefinitionInterface:
<?php namespace App\Hydrator; use App\Entity\User; use Netmex\HydratorBundle\Contracts\BuilderInterface; use Netmex\HydratorBundle\Contracts\MapperDefinitionInterface; use Netmex\HydratorBundle\Resolver\OptionsResolver; final class UserHydrator implements MapperDefinitionInterface { public function process(BuilderInterface $builder): void { $builder ->add('name') ->add('email'); } public function options(OptionsResolver $resolver): void { $resolver->setDefaults([ 'model' => User::class, ]); } }
Inject MapperInterface into your service or controller and use build():
$user = $mapper->build(UserHydrator::class, $inputData);
The input data should be an associative array containing the fields expected by the mapper.
Documentation
- Installation and configuration
- Basic usage
- Mapper options
- Transformers
- Validation
- Nested and recursive mapping
- Collection hydration
- Existing objects
- Error handling
Requirements
Check composer.json for the supported PHP and Symfony versions.
License
See the repository's LICENSE file.