dragon-code / laravel-json-response
Automatically always return a response in JSON format
Fund package maintenance!
Boosty
Yoomoney
Donationalerts
Installs: 15 454
Dependents: 1
Suggesters: 0
Security: 0
Stars: 11
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^8.1
- illuminate/contracts: ^10.0 || ^11.0
- illuminate/http: ^10.0 || ^11.0
- illuminate/support: ^10.0 || ^11.0
- lmc/http-constants: ^1.2
- symfony/http-foundation: ^6.0 || ^7.0
Requires (Dev)
- orchestra/testbench: ^8.0 || ^9.0
- phpunit/phpunit: ^10.0
Conflicts
README
Automatically always return a response in JSON format
Installation
Compatibility
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
.