2017 © Pedro Peláez
 

library payload

Middleware to parse the body of the request with support for json, csv and url-encode

image

middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  • Monday, June 25, 2018
  • by oscarotero
  • Repository
  • 2 Watchers
  • 10 Stars
  • 11,960 Installations
  • PHP
  • 5 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 25 % Grown

The README.md

middlewares/payload

Latest Version on Packagist ![Software License][ico-license] Testing ![Total Downloads][ico-downloads], (*1)

Parses the body of the request if it's not parsed and the method is POST, PUT or DELETE. It contains the following components to support different formats:, (*2)

Failure to parse the body will result in a Middlewares\Utils\HttpErrorException being thrown. See middlewares/utils for additional details., (*3)

Requirements

Installation

This package is installable and autoloadable via Composer as middlewares/payload., (*4)

composer require middlewares/payload

JsonPayload

Parses the JSON payload of the request., (*5)

Dispatcher::run([
    (new Middlewares\JsonPayload())
        ->associative(false)
        ->depth(64)
]);

$response = $dispatcher->dispatch(new ServerRequest());

Contains the following options to configure the json_decode function:, (*6)

associative

Enabled by default, convert the objects into associative arrays., (*7)

//Disable associative arrays
$payload = (new Middlewares\JsonPayload())->associative(false);

depth

To configure the recursion depth option of json_decode. By default is 512., (*8)

options

To pass the bitmask of json_decode options: JSON_BIGINT_AS_STRING (enabled by default), JSON_OBJECT_AS_ARRAY, JSON_THROW_ON_ERROR., (*9)

methods

To configure the allowed methods. By default only the requests with the method POST, PUT, PATCH, DELETE, COPY, LOCK, UNLOCK are handled., (*10)

//Parse json only with POST and PUT requests
$payload = (new Middlewares\JsonPayload())->methods(['POST', 'PUT']);

contentType

To configure all Content-Type headers allowed in the request. By default is application/json, (*11)

//Parse json only in request with these two Content-Type values
$payload = (new Middlewares\JsonPayload())->contentType(['application/json', 'text/json']);

override

To override the previous parsed body if exists (false by default), (*12)

UrlEncodePayload

Parses the url-encoded payload of the request., (*13)

Dispatcher::run([
    new Middlewares\UrlEncodePayload()
]);

methods

To configure the allowed methods. By default only the requests with the method POST, PUT, PATCH, DELETE, COPY, LOCK, UNLOCK are handled., (*14)

contentType

To configure all Content-Type headers allowed in the request. By default is application/x-www-form-urlencoded, (*15)

override

To override the previous parsed body if exists (false by default), (*16)

CsvPayload

CSV payloads are supported by the middlewares/csv-payload package., (*17)

XmlPayload

Parses the XML payload of the request. Parsed body will return an instance of SimpleXMLElement., (*18)

methods

To configure the allowed methods. By default only the requests with the method POST, PUT, PATCH, DELETE, COPY, LOCK, UNLOCK are handled., (*19)

contentType

To configure all Content-Type headers allowed in the request. By default is text/xml, application/xml and application/x-xml., (*20)

override

To override the previous parsed body if exists (false by default), (*21)


Please see CHANGELOG for more information about recent changes and CONTRIBUTING for contributing details., (*22)

The MIT License (MIT). Please see LICENSE for more information., (*23)

The Versions

25/06 2018

dev-master

9999999-dev https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 csv json server http psr-15 payload url-encode

25/06 2018

v2.0.0

2.0.0.0 https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 json server http psr-15 payload url-encode

25/01 2018

v1.0.0

1.0.0.0 https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 csv json server http psr-15 payload url-encode

13/11 2017

v0.6.0

0.6.0.0 https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 csv json server http psr-15 payload url-encode

21/09 2017

v0.5.0

0.5.0.0 https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 csv json server http psr-15 payload url-encode

05/02 2017

v0.4.0

0.4.0.0 https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 csv json server http psr-15 payload url-encode

26/12 2016

v0.3.0

0.3.0.0 https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 csv json server http psr-15 payload url-encode

27/11 2016

v0.2.0

0.2.0.0 https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 csv json server http psr-15 payload url-encode

04/10 2016

v0.1.0

0.1.0.0 https://github.com/middlewares/payload

Middleware to parse the body of the request with support for json, csv and url-encode

  Sources   Download

MIT

The Requires

 

The Development Requires

middleware psr-7 csv json server http psr-15 payload url-encode