open-cetacean / laravel-json-header by open-cetacean

Middleware to force Laravel API group to JSON header
756
0
2
Package Data
Maintainer Username: open-cetacean
Maintainer Contact: open-cetacean@users.noreply.github.com (Open Cetacean)
Package Create Date: 2017-01-26
Package Last Update: 2017-01-26
Language: PHP
License: MIT
Last Refreshed: 2024-10-28 15:02:01
Package Statistics
Total Downloads: 756
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 2
Total Forks: 0
Total Open Issues: 0

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.