kekos/parse-request-body-middleware

PSR-15 middleware for parsing requests with JSON and URI encoded bodies regardless of HTTP method.

v1.1.3 2024-11-25 21:07 UTC

This package is auto-updated.

Last update: 2024-11-25 21:38:40 UTC


README

PSR-15 middleware for parsing requests with JSON and URI encoded bodies regardless of HTTP method.

Install

You can install this package via Composer:

composer require kekos/multipart-form-data-parser

Documentation

Supported content types native PHP

* Supported by calling request_parse_body() in PHP >= 8.4

Supported content types this package

This package acts like a polyfill for unsupported content types (JSON) and types only supported in POST methods by PHP.

Usage

Add the \Kekos\ParseRequestBodyMiddleware\ParseRequestBodyMiddleware middleware to your PSR-15 handler, and it will populate ServerRequestInterface::getParsedBody() as array.

The parser will throw \Kekos\ParseRequestBodyMiddleware\ParserException if a malformed JSON body was sent.

Bugs and improvements

Report bugs in GitHub issues or feel free to make a pull request :-)

License

MIT