gepur-it/request-converter-bundle
Symfony bundle from gepur-it that converts incoming HTTP request data into structured, typed objects, helping keep controllers clean and request handling consistent across your application.
Install and register
composer require gepur-it/request-converter-bundle
Since this is a Symfony bundle, confirm registration in config/bundles.php:
return [
// ...
GepurIt\RequestConverterBundle\RequestConverterBundle::class => ['all' => true],
];
If config/bundles.php does not include it after composer require, add it manually — some small bundles ship without a Flex recipe, so auto-registration is not guaranteed.
Where to look first
vendor/gepur-it/request-converter-bundle/src/ — the service class and any controller trait/attribute are the real documentation.DependencyInjection/ — tells you the service ID (usually gepur_it.request_converter or similar) and what is autowirable.Resources/config/services.* — reveals constructor dependencies (Serializer, Validator, ParameterBag) so you know what it can actually do.First use case
The bundle's purpose is turning a raw Symfony\Component\HttpFoundation\Request into a typed object instead of hand-reading $request->request->get(...) or json_decode($request->getContent()). Start by replacing one manual JSON decode in an existing controller:
// Before
$data = json_decode($request->getContent(), true);
$dto = MyDto::fromArray($data);
// After (adjust to the actual API surface you find in src/)
$dto = $this->requestConverter->convert($request, MyDto::class);
That single swap is the fastest way to validate whether the bundle fits your codebase.
Controller-level DTO hydration
The primary pattern is: define a plain PHP DTO with public typed properties, then convert the request into it before your application logic runs.
final class CreateOrderInput
{
public string $reference;
public array $lines = [];
public ?string $note = null;
}
#[Route('/orders', methods: ['POST'])]
public function create(Request $request): Response
{
$input = $this->requestConverter->convert($request, CreateOrderInput::class);
// $input is now a typed object
}
Keep DTOs free of framework code — that makes them reusable across controllers, console commands, and tests.
Layer the conversion
For day-to-day use, treat the converter as the transport→DTO boundary and nothing more. Put business validation in Symfony's Validator afterward rather than expecting the converter to enforce rules:
$input = $this->requestConverter->convert($request, CreateOrderInput::class);
$errors = $this->validator->validate($input);
if (count($errors) > 0) {
throw new ValidationFailedException($errors);
}
Argument-resolver style (if supported)
If the bundle exposes an argument resolver or attribute, prefer it over injecting the service into every controller — it keeps controllers lean and makes the intent explicit:
public function create(#[ConvertRequest] CreateOrderInput $input): Response
{
// ...
}
Check src/ for an ArgumentResolver, Attribute, or Controller trait before writing manual wiring.
Integration tips
serializer config if the bundle leans on symfony/serializer, so property naming and denormalizers behave predictably.mapToInput()) inside a base controller if you need consistent error handling for malformed payloads.Small-package risk
This bundle has 1 star and 0 known dependents. That is fine for internal use, but budget for the possibility that it is unmaintained. Before adopting:
composer.json.composer.json require in the vendor folder).#[MapRequestPayload] (7.x) or symfony/serializer may already cover the same ground.Bundle registration
Missing bundle registration is the most common failure — you'll get a ServiceNotFoundException for the converter. If the service name is unclear, run:
php bin/console debug:container | grep -i converter
Serializer configuration quirks
If conversion relies on the Serializer, mismatched property names (snake_case payload vs camelCase DTO) silently result in null properties rather than errors. Enable serializer name_converter (MetadataAwareNameConverter) or add explicit #[SerializedName] attributes.
Silent empty results
Malformed or empty request bodies often produce an object with default values instead of throwing. Always validate the resulting DTO — never assume a successfully converted object means a valid payload.
Debugging conversion failures
NotNormalizableValueException, MissingConstructorArgumentsException) to see which field failed.$request->getContent() first — a 200 with a blank body looks identical to a conversion bug.Extension points
If the bundle permits custom normalizers/denormalizers or a custom converter implementation, register yours with a higher priority tag (e.g., serializer.normalizer with priority) instead of forking. Because the package is small, be prepared for the extension surface to be thin — the pragmatic fallback is a thin wrapper service of your own that delegates to symfony/serializer, keeping the bundle optional and replaceable.
How can I help you explore Laravel packages today?