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

This package is auto-updated.

Last update: 2024-01-27 00:37:42 UTC


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);