Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

TemirkhanN/dto-bundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dto-bundle

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
    }
}

About

DTO structures handler for symfony

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages