PHPackages                             juliangut/body-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PDF &amp; Document Generation](/categories/documents)
4. /
5. juliangut/body-parser

ActiveLibrary[PDF &amp; Document Generation](/categories/documents)

juliangut/body-parser
=====================

PSR7 body parser middleware

1.1(8y ago)110.1k1[1 issues](https://github.com/juliangut/body-parser/issues)BSD-3-ClausePHPPHP &gt;=5.6

Since Jan 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/juliangut/body-parser)[ Packagist](https://packagist.org/packages/juliangut/body-parser)[ Docs](https://github.com/juliangut/body-parser)[ RSS](/packages/juliangut-body-parser/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (10)Versions (4)Used By (0)

[![PHP version](https://camo.githubusercontent.com/957f92835f932441645ace4028bd11ed80ce25423944116fd564de89986db110/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344352e362d3838393242462e7376673f7374796c653d666c61742d737175617265)](http://php.net)[![Latest Version](https://camo.githubusercontent.com/2d4b04d88968f57558f0e26a5d59e4ce0dca473226c4caa20d2bbec86a3c4e1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a756c69616e6775742f626f64792d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/juliangut/body-parser)[![License](https://camo.githubusercontent.com/89c18457a844afd506e9679d678bf60950a32fad40a1cc46a219100b0853c7c8/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6a756c69616e6775742f626f64792d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://github.com/juliangut/body-parser/blob/master/LICENSE)

[![Build Status](https://camo.githubusercontent.com/22a9586cb82e034f32f284a845f39f6bed6859b060bd250d3d980ca1f77261ed/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a756c69616e6775742f626f64792d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/juliangut/body-parser)[![Style Check](https://camo.githubusercontent.com/ea2a4e9120421659ed04cb9185b678c1b4d6a2bca5cf5d0f990e519d611ed121/68747470733a2f2f7374796c6563692e696f2f7265706f732f37393236353331332f736869656c64)](https://styleci.io/repos/79265313)[![Code Quality](https://camo.githubusercontent.com/97bfaa92e9ae6138016c331222f2b8e709e50d5a74a15147935ca9b958e30d8a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6a756c69616e6775742f626f64792d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/juliangut/body-parser)[![Code Coverage](https://camo.githubusercontent.com/08b5ac70ed8e38072567f83756f16e94b44faf18d6b06498172ee65173b404d6/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6a756c69616e6775742f626f64792d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://coveralls.io/github/juliangut/body-parser)

[![Total Downloads](https://camo.githubusercontent.com/6ba0ebb5af62fc7d09f431348266387264b4b5f7e880c362f477f6ea137734c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a756c69616e6775742f626f64792d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/juliangut/body-parser)[![Monthly Downloads](https://camo.githubusercontent.com/f90f66ba7dd424f89784f64eb4b8453faace4b5916a59ef35bfc7c99d3818a41/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6a756c69616e6775742f626f64792d7061727365722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/juliangut/body-parser)

body-parser
===========

[](#body-parser)

PSR7 request body parser middleware.

PSR7 implementations doesn't normally parse request body to be available through `$request->getParsedBody()` or they only do it for certain request methods or content types.

The best way to be fully confident that your request content will be parsed correctly while using the PSR7 implementation that you want is through the use of a middleware responsible of this task.

Installation
------------

[](#installation)

### Composer

[](#composer)

```
composer require juliangut/body-parser

```

Usage
-----

[](#usage)

Add as many content decoders as you want to cover your application needs based on request's `Content-Type` header.

Decoders are assign to one or more HTTP methods.

Integrate in your middleware aware application workflow.

```
require './vendor/autoload.php';

use Jgut\BodyParser\Decoder\Json;
use Jgut\BodyParser\Decoder\Urlencoded;
use Jgut\BodyParser\Parser;
use Negotiator\Negtiator;

$bodyParser = new Parser(new Negotiator());
$bodyParser->addDecoder(new Urlencoded()); // Assigned to all requests
$bodyParser->addDecoder(new Json(), ['POST', 'PUT']); // Assigned only to POST and PUT requests

$app = new \YourMiddlewareAwareApplication();
$app->addMiddleware($bodyParser);
$app->run();
```

*Review the documentation of the PSR7 implementation you use as it may already parse request body in some cases. You don't want to do the same job twice.*

### Decoders

[](#decoders)

#### URL encoded

[](#url-encoded)

```
$decoder = new \Jgut\BodyParser\Decoder\UrlEncoded();
```

Supported MIME types:

- application/x-www-form-urlencoded

#### JSON

[](#json)

```
$decoder = new \Jgut\BodyParser\Decoder\Json();
```

Supported MIME types:

- application/json
- text/json
- application/x-json

#### XML

[](#xml)

```
$decoder = new \Jgut\BodyParser\Decoder\Xml();
```

Supported MIME types:

- application/xml
- text/xml
- application/x-xml

#### CSV

[](#csv)

```
$decoder = new \Jgut\BodyParser\Decoder\Csv($delimiter = ',', $enclosure = '"', $escape = '\\');
```

Supported MIME types:

- text/csv

#### Custom

[](#custom)

You can create your own decoder implementing `Jgut\BodyParser\Decoder\Decoder` interface.

For example you could implement a YAML decoder for `application/x-yaml` and `text/yaml` MIME types.

Contributing
------------

[](#contributing)

Found a bug or have a feature request? [Please open a new issue](https://github.com/juliangut/body-parser/issues). Have a look at existing issues before.

See file [CONTRIBUTING.md](https://github.com/juliangut/body-parser/blob/master/CONTRIBUTING.md)

License
-------

[](#license)

See file [LICENSE](https://github.com/juliangut/body-parser/blob/master/LICENSE) included with the source code for a copy of the license terms.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~135 days

Total

3

Last Release

3136d ago

Major Versions

0.1 → 1.02017-02-01

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c50421f1ab4148354dc2dd5dcaba168656b17ea913b310d112deb39a6f73ca1?d=identicon)[juliangut](/maintainers/juliangut)

---

Top Contributors

[![juliangut](https://avatars.githubusercontent.com/u/1104131?v=4)](https://github.com/juliangut "juliangut (15 commits)")

---

Tags

csvdecoderjsonmime-typespsr-7url-encodedxmlpsr7parsecontent-typebody

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/juliangut-body-parser/health.svg)

```
[![Health](https://phpackages.com/badges/juliangut-body-parser/health.svg)](https://phpackages.com/packages/juliangut-body-parser)
```

###  Alternatives

[mpdf/mpdf

PHP library generating PDF files from UTF-8 encoded HTML

4.7k77.1M493](/packages/mpdf-mpdf)[smalot/pdfparser

Pdf parser library. Can read and extract information from pdf file.

2.7k34.5M216](/packages/smalot-pdfparser)[gotenberg/gotenberg-php

A PHP client for interacting with Gotenberg, a developer-friendly API for converting numerous document formats into PDF files, and more!

3685.2M19](/packages/gotenberg-gotenberg-php)[akrabat/rka-content-type-renderer

Render an array to a JSON/XML/HTML PSR-7 Response based on a PSR-7 Request's Accept header.

40443.2k1](/packages/akrabat-rka-content-type-renderer)[rgilyov/laravel-csv-importer

Easy and reliable way to import, parse, validate and transform your csv files with laravel

166.1k](/packages/rgilyov-laravel-csv-importer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
