andrey-helldar/laravel-json-response

This package is abandoned and no longer maintained. The author suggests using the dragon-code/laravel-json-response package instead.

Automatically always return a response in JSON format

3.0.1 2024-04-01 21:21 UTC

This package is auto-updated.

Last update: 2024-04-01 21:26:05 UTC


README

Json Response for Laravel

Stable Version Unstable Version Total Downloads Github Workflow Status License

Automatically always return a response in JSON format

Installation

Compatibility

PHP Laravel Json Response
7.3, 7.4, 8.0, 8.1, 8.2, 8.3 6.x, 7.x, 8.x, 9.x, 10.x ^2.0
8.1, 8.2, 8.3 10.x, 11.x ^3.0

To get the latest version of Laravel Json Response, simply require the project using Composer:

composer require dragon-code/laravel-json-response

Or manually update require block of composer.json and run composer update.

{
    "require": {
        "dragon-code/laravel-json-response": "^3.0"
    }
}

Using

After you've installed the package via composer, you're done. There's no step two.

This package will automatically register the DragonCode\LaravelJsonResponse\Middlewares\SetHeaderMiddleware middleware in the web and api groups, if they exist. The middleware will add a header Accept that will effectively convert all responses to JSON format. This header will apply to all responses.

If you need to redefine the header for specific groups of routes, you can do this by changing the settings.