The package is PSR-15 middleware that allows parsing PSR-7 server request body selecting the parser according to the server request mime type.
- PHP 7.4 or higher.
The package could be installed with Composer:
composer require yiisoft/request-body-parser
- Add
RequestBodyParser
to your middleware stack. - Obtain parsed body via
$request->getParsedBody();
.
By default, it parses application/json
requests where JSON is in the body.
You can add your own parser by implementing ParserInterface
, adding it into the container and registering it within
the middleware:
$requestBodyParser = $requestBodyParser->withParser('application/myformat', MyFormatParser::class);
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
The Yii Request Body Parser is free software. It is released under the terms of the BSD License.
Please see LICENSE
for more information.
Maintained by Yii Software.