kekos / parse-request-body-middleware
PSR-15 middleware for parsing requests with JSON and URI encoded bodies regardless of HTTP method.
v1.1.2
2023-12-28 20:03 UTC
Requires
- php: ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0
- ext-json: *
- kekos/multipart-form-data-parser: ^1.1
- psr/http-factory: ^1.0
- psr/http-message: ^1.1 || ^2.0
- psr/http-server-middleware: ^1.0
Requires (Dev)
- nyholm/psr7: ^1.3
- nyholm/psr7-server: ^1.0
- phpstan/phpstan: ^1.8
- phpstan/phpstan-phpunit: ^1.1
- phpunit/phpunit: ^10.5
- rector/rector: ^0.18
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 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