dkx / psr7-request-body-mapper
This package is abandoned and no longer maintained.
No replacement package was suggested.
PSR7 request body mapper
1.0.0
2020-01-26 15:24 UTC
Requires
- php: >=7.4
- doctrine/annotations: ^1.8
- doctrine/cache: ^1.10
- phpdocumentor/reflection-docblock: ^4.3
- psr/http-message: ^1.0
- symfony/validator: ^5.0
Requires (Dev)
- dkx/composer-phar-installer: ^0.0.1
- doctrine/coding-standard: ^7.0
- mockery/mockery: ^1.3
- overtrue/phplint: ^1.2
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^0.12.5
- phpstan/phpstan-beberlei-assert: ^0.12.2
- phpstan/phpstan-mockery: ^0.12.3
- phpstan/phpstan-nette: ^0.12.3
- phpstan/phpstan-phpunit: ^0.12.6
- phpstan/phpstan-strict-rules: ^0.12.1
README
PSR7 request body mapper
Installation
$ composer require dkx/psr7-request-body-mapper
Usage
<?php
use DKX\Psr7RequestBodyMapper\BodyMapper;
use Symfony\Component\Validator\Validation;
class UserEntity
{
/**
* @Assert\Type("string")
* @Assert\NotBlank
* @Assert\Email
*/
public string $email;
/**
* @Assert\Type("string")
* @Assert\NotBlank
*/
public string $password;
}
$validator = Validation::createValidatorBuilder()
->enableAnnotationMapping()
->getValidator();
$mapper = new BodyMapper($validator);
/** @var UserEntity $user */
$user = $mapper->map($request, UserEntity::class);