dualmedia / symfony-request-dto-bundle
Symfony bundle which provides DTO object functionality and resolving
Package info
github.com/dualmediaspzoo/symfony-request-dto-bundle
Type:symfony-bundle
pkg:composer/dualmedia/symfony-request-dto-bundle
Requires
- php: >=8.5
- doctrine/collections: ^2.6
- dualmedia/doctrine-query-creator: ^1
- symfony/event-dispatcher: ^7.4||^8.0
- symfony/framework-bundle: ^7.4||^8.0
- symfony/type-info: ^7.4||^8.0
- symfony/validator: ^7.4||^8.0
Requires (Dev)
- ext-simplexml: *
- doctrine/doctrine-bundle: ^3
- doctrine/orm: ^3
- friendsofphp/php-cs-fixer: ^3
- jetbrains/phpstorm-attributes: ^1.2
- matthiasnoback/symfony-dependency-injection-test: ^6
- nelmio/api-doc-bundle: ^5
- pedrotroller/php-cs-custom-fixer: ^2
- phpstan/phpdoc-parser: ^2.3
- phpstan/phpstan: ^2
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^13
- pkly/phpunit-service-create-trait: ^1.0
- symfony/phpunit-bridge: ^7.4||^8.0
- symfony/stopwatch: ^7.4||^8.0
- symfony/var-exporter: ^7.4||^8.0
- symfony/web-profiler-bundle: ^7.4||^8.0
Suggests
- doctrine/doctrine-bundle: Symfony's ORM of choice
- nelmio/api-doc-bundle: Adds api docs for endpoints for your DTOs
- phpstan/phpdoc-parser: Better type resolving related to PHPDoc objects
Conflicts
- dev-master
- 4.0.10
- 4.0.9
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.4.1
- 3.4.0
- 3.3.0
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.0
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.1
- 2.1.0
- 1.0.0
- dev-fix/invalid-old-bag
- dev-fix/deduplicate-fields-openapi
- dev-fix/open-api-generate-with-children
- dev-fix/better-optional-params
- dev-fix/test-and-minor-things
- dev-fix/with-object-provider-closure-declaration
- dev-feature/deep-path-support
- dev-feature/add-virtual-field-description
This package is auto-updated.
Last update: 2026-04-24 13:29:54 UTC
README
This bundle aims to lower the burden of typechecking, casting, loading entities and related annoyances of using requests in your api.
Bundle will automatically hook into Doctrine ORM Bundle and Nelmio API Docs Bundle so no additional configuration should be needed.
Features
- Automatic DTO resolution from controller arguments — no manual extraction, casting, or validation wiring
- Type coercion for scalars, enums (backed or by case name), dates, and uploaded files
- Doctrine entity loading directly from request fields (
#[FindOneBy],#[FindBy]) - Validator integration — Symfony constraints on properties and fields are enforced in a single pass
- Nested DTOs, collections of DTOs, and
#[AsRoot]for flat top-level payloads - Nelmio API Doc integration — parameters, request bodies, enum cases, formats, and PHPDoc descriptions are described automatically
- Configurable request bags (query, body, headers, cookies, attributes, files) via
#[Bag] - Configurable custom
#[Action]s for fields, entities and more. Set custom responses via an easy to handle event. - Event hooks for resolved / invalid / action scenarios — return custom responses from listeners
- Symfony profiler panel with per-request DTO resolution timings
- Cached metadata via opcache-backed PHP files — near-zero reflection cost after warm-up
Install
composer require dualmedia/symfony-request-dto-bundle
Then add the bundle to your config/bundles.php file like so
return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], // other bundles ... DualMedia\DtoRequestBundle\DtoBundle::class => ['all' => true], ];
If applicable your Doctrine entity managers will be detected automatically and used as default providers for classes to be loaded with your requests if needed.
Quick start
use DualMedia\DtoRequestBundle\Dto\AbstractDto; use DualMedia\DtoRequestBundle\Dto\Attribute\Bag; use DualMedia\DtoRequestBundle\Metadata\Enum\BagEnum; use Symfony\Component\HttpFoundation\File\UploadedFile; // input: // [ // 'name' => 'John', // 'age' => '25', // 'score' => '9.5', // 'active' => '1', // 'avatar' => <UploadedFile>, // ] class ProfileDto extends AbstractDto { public string|null $name = null; public int|null $age = null; public float|null $score = null; public bool|null $active = null; #[Bag(BagEnum::Files)] public UploadedFile|null $avatar = null; }
More examples
See EXAMPLES.md for enums, dates, nested DTOs, entity loading, and root-level payloads.
Upgrades
See CHANGES.md