LaravelPackages.net
Acme Inc.
Toggle sidebar
open-cetacean/laravel-json-header

Middleware to force Laravel API group to JSON header

757
0
v1.0
About open-cetacean/laravel-json-header

open-cetacean/laravel-json-header is a Laravel package for middleware to force laravel api group to json header. It currently has 0 GitHub stars and 757 downloads on Packagist (latest version v1.0). Install it with composer require open-cetacean/laravel-json-header. Discover more Laravel packages by open-cetacean or browse all Laravel packages to compare alternatives.

Last updated

open-cetacean/laravel-json-header is a PHP package built for Laravel to force Laravel API group to JSON header activating wantsJson()

Installation

This project can be installed via Composer. Add the following line to the require block of your composer.json file:

{
    "require": {
            "open-cetacean/laravel-json-header": "^1.0"
    }

}

You'll then run composer install or composer update.

Or run the following command:

composer require open-cetacean/laravel-json-header

Middleware

To register the middleware add the following to the $routeMiddleware array within the app/Http/Kernel.php file:

protected $routeMiddleware = [
    // ...
    'acceptJson' => \OpenCetacean\JsonHeader\Middleware\AcceptJson::class,
    // ...
];

then add the middleware to your API routes:

Route::group(['middleware' => ['api', 'acceptJson']], function () {
    // ...
}

License

The MIT License (MIT). Please see License File for more information.

Comments