PHPackages                             softonic/laravel-request-accept-json-middleware - 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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. softonic/laravel-request-accept-json-middleware

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

softonic/laravel-request-accept-json-middleware
===============================================

Laravel middleware to add Accept application/json header to requests

5.0.0(4mo ago)450.8k↓48.6%Apache-2.0PHPPHP &gt;=8.5CI passing

Since Jul 26Pushed 4mo agoCompare

[ Source](https://github.com/softonic/laravel-request-accept-json-middleware)[ Packagist](https://packagist.org/packages/softonic/laravel-request-accept-json-middleware)[ Docs](https://github.com/softonic/laravel-request-accept-json-middleware)[ RSS](/packages/softonic-laravel-request-accept-json-middleware/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (12)Used By (0)

Laravel request accept json middleware
======================================

[](#laravel-request-accept-json-middleware)

[![Latest Version](https://camo.githubusercontent.com/ce9705ae08ec066385b3f5a182c3b1afdbae708ed78df6e895e6dd081c27885c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f736f66746f6e69632f6c61726176656c2d726571756573742d6163636570742d6a736f6e2d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://github.com/softonic/laravel-request-accept-json-middleware/releases)[![Software License](https://camo.githubusercontent.com/36cfc741510e076bec951c1421a2b1c3a5553e953fcdb378339626a5f33c1e8d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/5b0c626089ae945456daf3ddd356c3731987e30a293da7871cea45e2d78569dd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f66746f6e69632f6c61726176656c2d726571756573742d6163636570742d6a736f6e2d6d6964646c65776172652f74657374732e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/softonic/laravel-request-accept-json-middleware/actions)[![Coverage Status](https://camo.githubusercontent.com/1113cedbf764af2b1c841448f4be6ac14e7d314540e79d2d299ad570c5f97065/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f736f66746f6e69632f6c61726176656c2d726571756573742d6163636570742d6a736f6e2d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/softonic/laravel-request-accept-json-middleware/code-structure)[![Quality Score](https://camo.githubusercontent.com/c7533c4f5a67f3a8512fa5affe452b073ebbaea7e44a906b19407ec073cdb00a/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736f66746f6e69632f6c61726176656c2d726571756573742d6163636570742d6a736f6e2d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/softonic/laravel-request-accept-json-middleware)[![Total Downloads](https://camo.githubusercontent.com/b471ebde84c49e3a8703995028a516a01c3afa592867badd85f44f910a114e09/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f66746f6e69632f6c61726176656c2d726571756573742d6163636570742d6a736f6e2d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/softonic/laravel-request-accept-json-middleware)[![Average time to resolve an issue](https://camo.githubusercontent.com/0efaceb3c34b0f734a0c122eba0c643ff43a6c5a00b74615cdb3f757e82beced/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f7265736f6c7574696f6e2f736f66746f6e69632f6c61726176656c2d726571756573742d6163636570742d6a736f6e2d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](http://isitmaintained.com/project/softonic/laravel-request-accept-json-middleware "Average time to resolve an issue")[![Percentage of issues still open](https://camo.githubusercontent.com/05bd834867f785fa43ae4980f1591ec7f74b94f4150090ee61f9ec850c5a9149/687474703a2f2f697369746d61696e7461696e65642e636f6d2f62616467652f6f70656e2f736f66746f6e69632f6c61726176656c2d726571756573742d6163636570742d6a736f6e2d6d6964646c65776172652e7376673f7374796c653d666c61742d737175617265)](http://isitmaintained.com/project/softonic/laravel-request-accept-json-middleware "Percentage of issues still open")

This middleware adds the ability to automatically add the Accept application/json header to every request if it was not provided.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.5
- Laravel 12.x

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

[](#installation)

Via composer:

```
composer require softonic/laravel-request-accept-json-middleware

```

Documentation
-------------

[](#documentation)

To use the middleware register it in `app/Http/Kernel.php`

```
    protected $middleware
        = [
            ...
            RequestAcceptJson::class,
            ...
        ];

```

From now on the header `Accept: application/json` will be automatically added to every request.

Testing
-------

[](#testing)

`softonic/laravel-request-accept-json-middleware` has a [PHPUnit](https://phpunit.de) test suite, code style compliance check using [PHP CS Fixer](https://cs.symfony.com/), and static analysis using [PHPStan](https://phpstan.org/).

To run the tests, run the following command from the project folder:

```
$ docker compose run --rm test
```

To run PHPUnit only:

```
$ docker compose run --rm phpunit
```

To check code style:

```
$ docker compose run --rm php composer run phpcs
```

To fix code style issues:

```
$ docker compose run --rm fixcs
```

To run static analysis:

```
$ docker compose run --rm php composer run phpstan
```

License
-------

[](#license)

The Apache 2.0 license. Please see [LICENSE](LICENSE) for more information.

###  Health Score

56

—

FairBetter than 98% of packages

Maintenance77

Regular maintenance activity

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity83

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~262 days

Recently: every ~299 days

Total

10

Last Release

127d ago

Major Versions

1.0.0 → 2.0.02019-08-29

2.2.0 → 3.0.02020-11-02

3.2.0 → 4.0.02025-01-16

4.0.0 → 5.0.02026-01-12

PHP version history (3 changes)1.0.0PHP &gt;=7.2

4.0.0PHP &gt;=8.2

5.0.0PHP &gt;=8.5

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/524887?v=4)[Joskfg](/maintainers/Joskfg)[@joskfg](https://github.com/joskfg)

![](https://www.gravatar.com/avatar/a0d32fbf2a47dc28c1935adfc1c79c50d4b728eba55825377e549e934f1003a0?d=identicon)[devsoftonic](/maintainers/devsoftonic)

---

Top Contributors

[![joskfg](https://avatars.githubusercontent.com/u/524887?v=4)](https://github.com/joskfg "joskfg (5 commits)")[![rccrdpccl](https://avatars.githubusercontent.com/u/18526422?v=4)](https://github.com/rccrdpccl "rccrdpccl (3 commits)")[![Lotykun](https://avatars.githubusercontent.com/u/9845202?v=4)](https://github.com/Lotykun "Lotykun (2 commits)")[![xaviapa](https://avatars.githubusercontent.com/u/8439057?v=4)](https://github.com/xaviapa "xaviapa (2 commits)")[![Lotykun-Softonic](https://avatars.githubusercontent.com/u/130476160?v=4)](https://github.com/Lotykun-Softonic "Lotykun-Softonic (1 commits)")

---

Tags

acceptjsonlaravellaravel-middlewaremiddlewarerequestjsonmiddlewarelaravel

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/softonic-laravel-request-accept-json-middleware/health.svg)

```
[![Health](https://phpackages.com/badges/softonic-laravel-request-accept-json-middleware/health.svg)](https://phpackages.com/packages/softonic-laravel-request-accept-json-middleware)
```

###  Alternatives

[bmatovu/laravel-xml

Laravel XML Support

91270.4k](/packages/bmatovu-laravel-xml)[tucker-eric/laravel-xml-middleware

A Laravel Middleware to accept XML requests

181.2M](/packages/tucker-eric-laravel-xml-middleware)[json-mapper/laravel-package

The JsonMapper package for Laravel

25170.4k3](/packages/json-mapper-laravel-package)[novadaemon/filament-pretty-json

Read-only field to show pretty json in your filamentphp forms

44359.2k2](/packages/novadaemon-filament-pretty-json)[illuminatech/multipart-middleware

'multipart/form-data' parser middleware for Laravel

34268.8k](/packages/illuminatech-multipart-middleware)[danharper/laravel-jsonx

Add XML support to a JSON-speaking Laravel API with a single middleware via JSONx

1857.2k](/packages/danharper-laravel-jsonx)

PHPackages © 2026

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