Map request on your DTO object with zero configuration.

Overview

github actions Latest Stable Version Total Downloads License PHP Version Require

Map request on your DTO object with zero configuration.

Install

composer require prugala/symfony-request-dto

Usage

  1. Create a DTO that implements the interface rugala\RequestDto\Dto\RequestDtoInterface
  2. Use your DTO in a Controller e.g.: Controller
  3. Done, your JSON (other data are on TODO list) will be mapped on your object

Validation

You can use symfony/validator to validate request.
If you provide invalid data you will get response 400 with json object with violation list.

Example:

  1. Create DTO with constraint: DTO
  2. Call your action with JSON object: JSON
  3. You get response 400 with JSON: JSON

If you want to change response format, overwrite method formatErrors in listener Prugala\RequestDto\EventListener\RequestValidationExceptionListener

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

composer tests

TODO

  • add support for form data
  • add support for query data
  • add support for upload files

Contributing

Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

You might also like...
Allows generate class files parse from json and map json to php object, including multi-level and complex objects;

nixihz/php-object Allows generate class files parse from json and map json to php object, including multi-level and complex objects; Installation You

PHP library that helps to map any input into a strongly-typed value object structure.

Valinor • PHP object mapper with strong type support Valinor is a PHP library that helps to map any input into a strongly-typed value object structure

Routing - The Routing component maps an HTTP request to a set of configuration variables.

Routing Component The Routing component maps an HTTP request to a set of configuration variables. Getting Started $ composer require symfony/routing

This Package helps you in laravel application to log all desired activity for each request from request entry point to generate response at a single snapshot.

Laravel Scenario Logger This Package helps you in laravel application to log all desired activity for each request from request entry point to generat

Csrf Component provides Cross Site Request Forgery protection by comparing provided token with session token to ensure request validity.

Csrf Component Csrf Component provides Cross Site Request Forgery protection by comparing provided token with session token to ensure request validity

HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast usage.

HttpRequestor from Patienceman HTTP Requestor: Package for a client request that supports you to make an external service request easily and with fast

An article about alternative solution for convert object into a JSON Object for your api.

Do we really need a serializer for our JSON API? The last years I did build a lot of JSON APIs but personally was never happy about the magic of using

Your alter ego object. Takes the best of object and array worlds.

Supporting Opensource formapro\values is an MIT-licensed open source project with its ongoing development made possible entirely by the support of com

provides a nested object property based user interface for accessing this configuration data within application code

laminas-config This package is considered feature-complete, and is now in security-only maintenance mode, following a decision by the Technical Steeri

Laravel-model-mapper - Map your model attributes to class properties with ease.
Laravel-model-mapper - Map your model attributes to class properties with ease.

Laravel Model-Property Mapper This package provides functionality to map your model attributes to local class properties with the same names. The pack

A simple PHP library to transfer data from a source (object or array) to an object.

SimplexMapper A simple PHP library to transfer data from a source (object or array) to an object. $dbData = [ 'username' = 'pfazzi', 'emailAd

Zero-Config plugin to disable FLoC in your WordPress Website.
Zero-Config plugin to disable FLoC in your WordPress Website.

Disable FLoC by WP Munich A simple zero-config plugin to opt-out of Google FLoC. This plugin is made with love and brought to you by the folks of WP M

Map nested JSON structures onto PHP classes

JsonMapper - map nested JSON structures onto PHP classes Takes data retrieved from a JSON web service and converts them into nested object and arrays

EXPERIMENTAL plugin extending WPGraphQL to support querying (Gutenberg) Blocks as data, using Server Side Block registries to map Blocks to the GraphQL Schema.

WPGraphQL Block Editor This is an experimental plugin to work toward compatiblity between the WordPress Gutenberg Block Editor and WPGraphQL, based on

PrestaShop module that allows an ecommerce/brand to display its physical retailers in a map

PrestaShop module that allows an ecommerce/brand to display its physical retailers in a map Features Free of charge: instead of using pa

JsonMapper - map nested JSON structures onto PHP classes

Takes data retrieved from a JSON web service and converts them into nested object and arrays - using your own model classes.

PHP library to easily get static image from French Cadastral Government map with markers and lines.
PHP library to easily get static image from French Cadastral Government map with markers and lines.

PHP French Cadastral Map Static API PHP library to easily get static image from French Cadastral Government map with markers and lines. Map source : c

Ormapker is a wordpress plugin to embbed a multilocations map easily.

ORMAPKER Ormapker is a wordpress plugin to embbed a multilocations map easily. License This plugin is released under the GNU General Public License Ve

Comments
  • Add support for form data, query and files

    Add support for form data, query and files

    Description

    Map data from form data, query parameters, and files to DTO. Remember to handle bad request exceptions for for these types, so as not to return 400 with json.

    Possible implementation

    Hint: $request->request->all() $request->request->files->all()

    enhancement good first issue 
    opened by prugala 0
  • Deserialization error

    Deserialization error

    Description

    When model property is not nullable deserialization can throw fatal error. Validator should be performed before deserialization.

    #[Assert\NotNull(message: 'cannot_be_null')] public string $password;

    will throw 500 when password is given but null Failed to denormalize attribute "password" value for class [...] Expected argument of type "string", "null" given at property path "password".

    bug 
    opened by KrzysztofWitek 0
Releases(1.1.0)
Owner
Piotr Rugala
Piotr Rugala
LOAD is a PHP library for configuration loading to APCu

LOAD LOAD is a PHP library for configuration loading to APCu Sources Available sources for configuration loading are: PHP file Consul Environment vari

Beat Labs 4 Jan 18, 2022
A better YAML configuration file management virion for PocketMine-MP 4

BetterConfig WARNING: This virion is under development and haven't been tested. Do not use this virion unless you know what you're doing. Contribution

KygekTeam International 1 Apr 30, 2022
Config is a file configuration loader that supports PHP, INI, XML, JSON, YML, Properties and serialized files and string

Config Config is a file configuration loader that supports PHP, INI, XML, JSON, YML, Properties and serialized files and strings. Requirements Config

Hassan Khan 948 Nov 27, 2022
zend-config is designed to simplify access to configuration data within applications

zend-config is designed to simplify access to configuration data within applications

Zend Framework 89 Jan 13, 2022
Yaml Configuration support for CakePHP 3

implements most of the YAML 1.2 specification using Symfony Yaml Component to CakePHP 3 for parsing config files

Borhaneddine Guemidi 11 Nov 10, 2020
An object-oriented option parser library for PHP, which supports type constraints, flag, multiple flag, multiple values, required value checking

GetOptionKit Code Quality Versions & Stats A powerful option parser toolkit for PHP, supporting type constraints, flag, multiple flag, multiple values

Yo-An Lin 140 Sep 28, 2022
DTO Generator - PHP library for generating DTO classes

DTO Generator PHP library for generating DTO classes. Installation Use the package manager composer to install micro/dto. composer require micro/dto U

Micro PHP Framework 7 Sep 6, 2022
A lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5.

Idiorm http://j4mie.github.com/idiormandparis/ Feature/API complete Idiorm is now considered to be feature complete as of version 1.5.0. Whilst it wil

Jamie Matthews 2k Nov 27, 2022
📦 A zero-configuration #0CJS developer toolkit for building WordPress Gutenberg block plugins.

create-guten-block is zero configuration dev-toolkit (#0CJS) to develop WordPress Gutenberg blocks in a matter of minutes without configuring React, w

Ahmad Awais ⚡️ 3.1k Nov 30, 2022
Low code , Zero Configuration ORM that creates models, config, database and tables on the fly.

?? ARCA ORM ?? Low code , Zero Configuration ORM that creates models, config, database and tables on the fly. ?? ???? Made in India ???? Complete docu

Scrawler Labs 26 Nov 14, 2022