therour / your-json-response
modifier for json response skeleton
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
pkg:composer/therour/your-json-response
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2025-10-29 02:23:16 UTC
README
INSTALLATION
via Composer
composer require therour/your-json-response
For Laravel 5.4 and below Add Service Provider to config/app.php of your laravel project
'providers' => [ ... Therour\YourJsonResponse\ServiceProvider::class, ]
CONFIGURATION
publish configuration file
php artisan vendor:publish --provider=Therour\YourJsonResponse\ServiceProvider
the configuration file is located at your laravel's config directory by name yjresponse.php
USAGE
this package is bundled with named skeleton ok, you can edit the skeleton in config yjresponse.php
return response()->ok($data, $message = 'success', $code = 200); // or return response()->yourNamedSkeleton($data, $message = 'success', $code = 200);
CREATING SKELETON
open configuration file yjresponse.php
use code, message, data, type, and meta_page as value of skeleton to place it
EG:
'skeleton' => [ ... // 'created' is the name of skeleton, and its value is the skeleton 'created' => [ 'status' => [ 'code', 'message' ], 'result' => 'data' ] ],
at the same file, also define the default value
'defaults' => [ ... 'created' => [ 'code' => 201, 'message' => 'Succesfully create the object' ] ]
Use your custom skeleton
return response()->created($product);
result
{
"status": {
"code": 201,
"message": "Succesfully create the object"
},
"result": {
"name": "Product X",
"price": 6000,
"weight": 500
}
}