temirkhan / dto-bundle
DTO handler bundle for symfony projects
Installs: 92
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/temirkhan/dto-bundle
Requires
- php: ^7.3
- ext-json: *
- spatie/data-transfer-object: ^1.13|^2.5
- symfony/dependency-injection: ^4.1|^5.0
- symfony/http-kernel: ^4.1|^5.1
Requires (Dev)
- phpunit/phpunit: ^9.3
This package is auto-updated.
Last update: 2020-09-24 07:03:09 UTC
README
DTO structures handler for symfony
NOTICE
This package has been transfered to https://github.com/vseinstrumentiru/dto-bundle and won't receive further updates.
Installation
$ composer require temirkhan/dto-bundle
Include bundle in your config
// config/bundles.php return [ \Temirkhan\DataObjectBundle\DataObjectBundle::class => ['all' => true], ];
Usage
<?php use Spatie\DataTransferObject\DataTransferObject; class RegistrationDto extends DataTransferObject { /** @var string */ public $login; /** @var string */ public $password; } class RegistrationController { public function __invoke(RegistrationDto $registration): JsonResponse { // Data is filled from Request::$request(or content if json) and ready for usage // Resolver will fail with BadRequest response if type or field mismatch. // Normally one needs validation so feel free using constraint annotations in dto // and validate dto here via symfony validator } }