yiisoft / request-body-parser
Middleware for parsing various data formats
Fund package maintenance!
Open Collective
yiisoft
Installs: 31 901
Dependents: 4
Suggesters: 0
Security: 0
Stars: 12
Watchers: 15
Forks: 5
Open Issues: 3
Requires
- php: ^7.4|^8.0
- ext-json: *
- psr/container: ^1.0|^2.0
- psr/http-message: ^1.0
- psr/http-message-implementation: 1.0
- psr/http-server-handler: ^1.0
- psr/http-server-middleware: ^1.0
- yiisoft/http: ^1.2
Requires (Dev)
- nyholm/psr7: ^1.0
- phpunit/phpunit: ^9.5
- roave/infection-static-analysis-plugin: ^1.16
- spatie/phpunit-watcher: ^1.23
- vimeo/psalm: ^4.18
- yiisoft/test-support: ^1.3
This package is auto-updated.
Last update: 2023-10-01 00:17:11 UTC
README
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.
General usage
- 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);
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
Follow updates
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.