PHP code example of prugala / symfony-request-dto

1. Go to this page and download the library: Download prugala/symfony-request-dto library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

prugala / symfony-request-dto example snippets

 
    
   declare(strict_types=1);
   
   namespace App\Controller;
   
   use Symfony\Component\HttpFoundation\JsonResponse;
   use App\Dto\ExampleDto;
   
   class ExampleController
   {
        public function update(ExampleDto $dto): JsonResponse
        {
            return new JsonResponse($dto);
        }
   }
    

    #[Assert\File(maxSize: 1000, mimeTypes: 'text/plain')]
    public ?UploadedFile $exampleFile = null;
 
    
    declare(strict_types=1);

    namespace App\Dto;

    use Prugala\RequestDto\Dto\RequestDtoInterface;
    use Symfony\Component\Validator\Constraints as Assert;
    
    class ExampleDto implements RequestDtoInterface
    {
        public string $name;

        #[Assert\Range(min: 2, max: 10)]
        public int $position;
    }