Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fernandozueet/response-laravel
Library for standardization of error messages and success of api json.
https://github.com/fernandozueet/response-laravel
messages response response-errors response-laravel response-messages
Last synced: 26 days ago
JSON representation
Library for standardization of error messages and success of api json.
- Host: GitHub
- URL: https://github.com/fernandozueet/response-laravel
- Owner: FernandoZueet
- License: mit
- Created: 2019-04-30T17:55:47.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-30T12:22:40.000Z (over 4 years ago)
- Last Synced: 2024-12-16T10:53:02.526Z (about 2 months ago)
- Topics: messages, response, response-errors, response-laravel, response-messages
- Language: PHP
- Size: 5.86 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Response laravel
Library for standardization of error messages and success of api json.
---
## Requirements
- PHP 7.0 or newer;
- Laravel 5.8 or newer;---
## Installation
```bash
composer require fernandozueet/response-laravel
```---
Response status 204:
status 204
```php
return respond_empty();
```---
Response success:
status 200
```php
return respond_success('Record changed successfully.');//or
//create translation file
return respond_success('filex.record_success');
``````json
{
"status": "success",
"message": "Record changed successfully."
}
```---
Response success and included data:
status 200
```php
return respond_success('Record changed successfully', [ 'type' => 1 ]);
``````json
{
"status": "success",
"message": "Record changed successfully.",
"data": {
"type": 1
}
}
```---
Response created:
status 201
```php
return respond_created('Record created successfully.');
``````json
{
"status": "success",
"message": "Record created successfully."
}
```---
Response created and included data:
status 201
```php
return respond_created('Record created successfully.', [ 'type' => 1 ]);
``````json
{
"status": "success",
"message": "Record created successfully.",
"data": {
"type": 1
}
}
```---
Response error:
status 400
```php
return respond_error('Error while changing registry.');
``````json
{
"status": "error",
"message": "Error while changing registry."
}
```---
Response error and included data:
status 400
```php
return respond_error('Error while changing registry.', [ 'type' => 1 ]);
``````json
{
"status": "error",
"message": "Error while changing registry.",
"data": {
"type": 1
}
}
```---
Response error:
status 401
```php
return respond_unauthorized();
``````json
{
"status": "error",
"message": "Unauthenticated."
}
```---
## Contributing
Please see [CONTRIBUTING](https://github.com/FernandoZueet/response-laravel/graphs/contributors) for details.
## Security
If you discover security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [Fernando Zueet](https://github.com/FernandoZueet)
## License
The package is licensed under the MIT license. See [License File](LICENSE.md) for more information.