fernandozueet / response-laravel
Library for standardization of error messages and success of api json.
Installs: 80
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/fernandozueet/response-laravel
Requires
- php: >=7.0.0
Requires (Dev)
- phpunit/dbunit: >=1.2
- phpunit/phpunit: 5.5.*
- phpunit/phpunit-selenium: >=1.2
This package is auto-updated.
Last update: 2025-09-29 02:15:13 UTC
README
Library for standardization of error messages and success of api json.
Requirements
- PHP 7.0 or newer;
- Laravel 5.8 or newer;
Installation
composer require fernandozueet/response-laravel
Response status 204:
status 204
return respond_empty();
Response success:
status 200
return respond_success('Record changed successfully.'); //or //create translation file return respond_success('filex.record_success');
{
"status": "success",
"message": "Record changed successfully."
}
Response success and included data:
status 200
return respond_success('Record changed successfully', [ 'type' => 1 ]);
{
"status": "success",
"message": "Record changed successfully.",
"data": {
"type": 1
}
}
Response created:
status 201
return respond_created('Record created successfully.');
{
"status": "success",
"message": "Record created successfully."
}
Response created and included data:
status 201
return respond_created('Record created successfully.', [ 'type' => 1 ]);
{
"status": "success",
"message": "Record created successfully.",
"data": {
"type": 1
}
}
Response error:
status 400
return respond_error('Error while changing registry.');
{
"status": "error",
"message": "Error while changing registry."
}
Response error and included data:
status 400
return respond_error('Error while changing registry.', [ 'type' => 1 ]);
{
"status": "error",
"message": "Error while changing registry.",
"data": {
"type": 1
}
}
Response error:
status 401
return respond_unauthorized();
{
"status": "error",
"message": "Unauthenticated."
}
Contributing
Please see CONTRIBUTING for details.
Security
If you discover security related issues, please email fernandozueet@hotmail.com instead of using the issue tracker.
Credits
License
The package is licensed under the MIT license. See License File for more information.