PHPackages                             pfilsx/dto-param-converter-bundle - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. pfilsx/dto-param-converter-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

pfilsx/dto-param-converter-bundle
=================================

This Symfony bundle provides a way to convert requests into dto easily

v2.0.3(3y ago)798.7k↓34.8%1MITPHPPHP ^7.4 || ^8.0

Since Mar 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/pfilsx/DtoParamConverterBundle)[ Packagist](https://packagist.org/packages/pfilsx/dto-param-converter-bundle)[ RSS](/packages/pfilsx-dto-param-converter-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (16)Versions (19)Used By (0)

DTO Param Converter Bundle
==========================

[](#dto-param-converter-bundle)

[![PHP Version Require](https://camo.githubusercontent.com/208101b8d35c2592be583c27ada30e3dbe9215cd8dd02c5ec7a228ab041917c3/687474703a2f2f706f7365722e707567782e6f72672f7066696c73782f64746f2d706172616d2d636f6e7665727465722d62756e646c652f726571756972652f706870)](https://packagist.org/packages/pfilsx/dto-param-converter-bundle)[![Latest Stable Version](https://camo.githubusercontent.com/32542fc0b8d569888d919ead0e505d307ee81f2b5554be22c92bb15b2ba32216/687474703a2f2f706f7365722e707567782e6f72672f7066696c73782f64746f2d706172616d2d636f6e7665727465722d62756e646c652f76)](https://packagist.org/packages/pfilsx/dto-param-converter-bundle)
[![Tests](https://github.com/pfilsx/DtoParamConverterBundle/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/pfilsx/DtoParamConverterBundle/actions/workflows/ci.yaml)[![Total Downloads](https://camo.githubusercontent.com/80c170e35eb200a44d49813df70a2d1e8115b3c94ca5b6893e4a12bdef968231/687474703a2f2f706f7365722e707567782e6f72672f7066696c73782f64746f2d706172616d2d636f6e7665727465722d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/pfilsx/dto-param-converter-bundle)

Description
-----------

[](#description)

The bundle provides a simple way to map requests into DTO(Data Transfer Object), validate and inject into Your Symfony project controller. It automatically deserealize request content into provided DTO, validates it (if required) and injects DTO into your controller argument([Symfony Argument Resolver](https://symfony.com/doc/current/controller/argument_value_resolver.html)), and finally you have a fully valid DTO in your controller.

Features
--------

[](#features)

- Request deserialization into dto with configurable serializer
- Automatic configurable validation using [Symfony validator](https://symfony.com/doc/current/validation.html)
- Easy to configure converter options for each request/DTO via annotations/PHP8 attributes(preload, serializer, validator options etc)
- Entity preload into DTO before request deserialization

Requirement
-----------

[](#requirement)

- PHP 7.4+|8.x
- Symfony 4.4+|5.3+|6.0+

Installation
------------

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest version of this bundle:

```
composer require pfilsx/dto-param-converter-bundle
```

Register bundle into `config/bundles.php` (Flex did it automatically):

```
return [
    ...
    Pfilsx\DtoParamConverter\DtoParamConverterBundle::class => ['all' => true],
];
```

Documentation
-------------

[](#documentation)

Documentation can be found [here](src/Resources/doc/index.rst).

Usage
-----

[](#usage)

1. Create DTO class with converter annotation/attribute

```
use Pfilsx\DtoParamConverter\Annotation\Dto;
use Symfony\Component\Validator\Constraints as Assert;

/**
* @Dto()
*/
final class SomeDto
{
  /**
  * @Assert\NotBlank
  */
  public ?string $title = null;

  ...
}
```

2. Use DTO in your controller

```
public function postAction(SomeDto $someDto): Response
{
    // here dto already loaded and validated
}
```

3. Link DTO with entity(if preload required)

```
/**
* @Dto(linkedEntity=SomeEntity::class)
*/
final class SomeDto
{
    ...
}
```

4. Create entity-dto mapper(if preload required)

```
use Pfilsx\DtoParamConverter\Contract\DtoMapperInterface;

final class SomeDtoMapper implements DtoMapperInterface
{
    public static function getDtoClassName(): string
    {
        return SomeDto::class;
    }

    /**
     * @param object|SomeEntity   $entity
     * @param SomeDto|object $dto
     */
    public function mapToDto(object $entity, object $dto): void
    {
        // your entity to dto mapping logic
        $dto->title = $entity->getTitle();
        ...
    }
}
```

Configuration
-------------

[](#configuration)

You can configure bundle globally via `config/packages/dto_param_converter.yaml`:

```
dto_param_converter:
  preload: # entity preload into dto configuration
    enabled: true # enable/disable entity preloading before request mapping
    methods: ['GET', 'PATCH'] # request methods that require the entity preload
    optional: false # if false the converter will throw NotFoundHttpException on entity for preloading not found otherwise it will ignore preloading
    entity_manager_name: null # entity manager name to use for entity preloading. useful on multiple managers
  serializer: # request deserialization configuration
    service: serializer # serializer should be used for request deserialization
    normalizer_exception_class: 'Pfilsx\DtoParamConverter\Exception\NotNormalizableConverterValueException' # exception class that should be thrown on normalization errors. not actual after 5.4 symfony/serializer
    strict_types: # types enforcement on denormalization
      enabled: true
      excluded_methods: ['GET'] # excluded request methods for types enforcement
  validation: # dto validation configuration
    enabled: true # enable/disable validation of dto
    excluded_methods: ['GET'] # excluded request methods for validation
    exception_class: 'Pfilsx\DtoParamConverter\Exception\ConverterValidationException' # exception class that should be thrown on validation errors
```

Or You can configure converter for each action

```
/**
* @DtoResolver(options={
*    DtoArgumentResolver::OPTION_SERIALIZER_CONTEXT: {},
*    DtoArgumentResolver::OPTION_VALIDATOR_GROUPS: {},
*    DtoArgumentResolver::OPTION_PRELOAD_ENTITY: true,
*    DtoArgumentResolver::OPTION_STRICT_PRELOAD_ENTITY: true,
*    DtoArgumentResolver::OPTION_ENTITY_ID_ATTRIBUTE: null,
*    DtoArgumentResolver::OPTION_ENTITY_MANAGER: null,
*    DtoArgumentResolver::OPTION_ENTITY_MAPPING: {}
*    DtoArgumentResolver::OPTION_ENTITY_EXPR: null,
*    DtoArgumentResolver::OPTION_VALIDATE: false
* })
*/
public function someAction(SomeDto $someDto): Response
{
    ...
}
```

License
-------

[](#license)

This bundle is released under the MIT license.

Contribute
----------

[](#contribute)

If you'd like to contribute, feel free to propose a pull request, create issue or just contact me :)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity36

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity66

Established project with proven stability

 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 ~70 days

Recently: every ~141 days

Total

17

Last Release

771d ago

Major Versions

v1.4.0 → v2.0.02022-06-19

2.0.x-dev → 3.0.x-dev2024-04-07

PHP version history (3 changes)v1.0.0PHP &gt;=7.4

v1.3.0PHP ^7.4 || ^8.0

3.0.x-devPHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3a454338d7c66e09ecdccd0f29802a3d7cca1498617cab6166285cad547c3734?d=identicon)[Pfilsx](/maintainers/Pfilsx)

---

Top Contributors

[![pfilsx](https://avatars.githubusercontent.com/u/29336048?v=4)](https://github.com/pfilsx "pfilsx (76 commits)")

---

Tags

argument-resolverdtoparam-converterphpsymfonysymfony-bundleapisymfonybundlerestparam-converter

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/pfilsx-dto-param-converter-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/pfilsx-dto-param-converter-bundle/health.svg)](https://phpackages.com/packages/pfilsx-dto-param-converter-bundle)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k48.1M236](/packages/api-platform-core)[api-platform/symfony

Symfony API Platform integration

323.2M67](/packages/api-platform-symfony)[api-platform/serializer

API Platform core Serializer

223.4M31](/packages/api-platform-serializer)[web-auth/webauthn-framework

FIDO2/Webauthn library for PHP and Symfony Bundle.

50570.7k1](/packages/web-auth-webauthn-framework)[cypresslab/patch-manager

A library to manage patch requests

16117.4k](/packages/cypresslab-patch-manager)

PHPackages © 2026

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