yiisoft / request-body-parser
Middleware for parsing various data formats
Fund package maintenance!
Opencollective
yiisoft
Installs: 48 351
Dependents: 4
Suggesters: 0
Security: 0
Stars: 15
Watchers: 17
Forks: 8
Open Issues: 4
Requires
- php: ^7.4|^8.0
- ext-json: *
- psr/container: ^1.0|^2.0
- psr/http-message: ^1.0|^2.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: 2024-11-09 11:57:20 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.
Requirements
- PHP 7.4 or higher.
Installation
The package could be installed with Composer:
composer require yiisoft/request-body-parser
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);
Documentation
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.
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.