Laravel middleware to add Accept application/json header to requests
softonic/laravel-request-accept-json-middleware is a Laravel package for laravel middleware to add accept application/json header to requests.
It currently has 4 GitHub stars and 52.333 downloads on Packagist (latest version 5.0.0).
Install it with composer require softonic/laravel-request-accept-json-middleware.
Discover more Laravel packages by softonic
or browse all Laravel packages to compare alternatives.
Last updated
This middleware adds the ability to automatically add the Accept application/json header to every request if it was not provided.
Via composer:
composer require softonic/laravel-request-accept-json-middleware
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.
softonic/laravel-request-accept-json-middleware has a PHPUnit test suite, code style compliance check using PHP CS Fixer, and static analysis using PHPStan.
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
The Apache 2.0 license. Please see LICENSE for more information.