yiisoft/request-body-parser

Middleware for parsing various data formats

1.1.0 2022-07-01 18:34 UTC

This package is auto-updated.

Last update: 2024-03-30 00:19:14 UTC


README

68747470733a2f2f796969736f66742e6769746875622e696f2f646f63732f696d616765732f7969695f6c6f676f2e737667

Yii Request Body Parser


The package is PSR-15 middleware that allows parsing PSR-7 server request body selecting the parser according to the server request mime type.

Latest Stable Version Total Downloads Build status Scrutinizer Code Quality Code Coverage Mutation testing badge static analysis type-coverage

General usage

  1. Add RequestBodyParser to your middleware stack.
  2. 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);

Unit testing

The package is tested with PHPUnit. To run tests:

./vendor/bin/phpunit

Mutation testing

The package tests are checked with Infection mutation framework. To run it:

./vendor/bin/infection

Static analysis

The code is statically analyzed with Psalm. To run static analysis:

./vendor/bin/psalm

Support the project

Open Collective

Follow updates

Official website Twitter Telegram Facebook Slack

License

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.