componenta/http-body-parsing-middleware

PSR-15 request body parsing middleware for Componenta

Maintainers

Package info

github.com/componenta/http-body-parsing-middleware

pkg:composer/componenta/http-body-parsing-middleware

Statistics

Installs: 7

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-15 10:59 UTC

This package is auto-updated.

Last update: 2026-06-15 12:06:41 UTC


README

PSR-15 middleware for parsing HTTP request bodies into PSR-7 parsed body and uploaded files. It supports JSON, application/x-www-form-urlencoded, and multipart/form-data.

Use this package in HTTP applications that need parsed bodies for methods and content types PHP does not parse natively.

Installation

composer require componenta/http-body-parsing-middleware

The package exposes Componenta\Http\Middleware\BodyParsingConfigProvider through Composer metadata.

Configuration

The config provider registers BodyParsingMiddleware from:

  • StreamFactoryInterface
  • UploadedFileFactoryInterface

Install one PSR-7/PSR-17 integration package so these factories exist in the container.

Runtime Behavior

The middleware skips requests when:

  • getParsedBody() is already set;
  • the method is GET, HEAD, OPTIONS, or TRACE;
  • PHP has already parsed a native POST form or multipart request.

Scalar JSON values are preserved under the __scalar key because PSR-7 parsed bodies must be null, array, or object.

Public Classes

  • BodyParsingMiddleware is the PSR-15 middleware.
  • Body\MultipartParser parses multipart bodies.
  • Body\MultipartPart represents one multipart part.

Related Packages