https://github.com/antare74/response-formatter
I created this package to make it easier to format the response from a controller. I have used this package in my projects and I hope you enjoy it!
https://github.com/antare74/response-formatter
bettercodehub collaborate educative github github-campus-experts gitlens laravel learn php student-vscode
Last synced: 6 months ago
JSON representation
I created this package to make it easier to format the response from a controller. I have used this package in my projects and I hope you enjoy it!
- Host: GitHub
- URL: https://github.com/antare74/response-formatter
- Owner: antare74
- Archived: true
- Created: 2022-07-01T05:41:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-03T05:24:19.000Z (about 3 years ago)
- Last Synced: 2025-04-13T17:50:42.181Z (10 months ago)
- Topics: bettercodehub, collaborate, educative, github, github-campus-experts, gitlens, laravel, learn, php, student-vscode
- Language: PHP
- Homepage:
- Size: 14.6 KB
- Stars: 19
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
Laravel Response Formatter
[]()
[](https://github.com/antare74/response-formatter/issues)
[](https://github.com/antare74/response-formatter/pulls)
[](/LICENSE)
---
I created this package to make it easier to format the response from a controller. I have used this package in my projects and I hope you enjoy it!
## 📝 Table of Contents
- [About](#about)
- [Getting Started](#getting_started)
- [Usage](#usage)
- [Contributing](../CONTRIBUTING.md)
- [Authors](#authors)
- [Acknowledgments](#acknowledgement)
## 🧐 About
It is a simple package that allows you to format your response in a consistent way. This might be useful for your API, or for your front-end.
## 🏁 Getting Started
These instructions will help you get started with your project.
### Prerequisites
What things you need to install the software and how to install them.
```
composer
```
```
Laravel Version: >= 5.8
```
### Installing
A step by step series of examples that tell you how to get a development env running.
```
composer require antare74/response-formatter
```
Example Usage.
```
'Antare74',
'age' => '74',
'address' => 'Jakarta',
], 'Success Message');
});
Route::get('/error', function () {
return Format::error([
'my_error_data' => 'Error Message',
], 'Error Message', 500);
});
```
Example Success Response.
```
{
"meta": {
"code": 200,
"status": "success",
"message": "Success Message",
"is_paginated": false
},
"pagination": [
],
"data": {
"name": "Antare74",
"age": "74",
"address": "Jakarta"
}
}
```
Example Error Response.
```
{
"meta": {
"code": 500,
"status": "error",
"message": "Error Message",
"is_paginated": false
},
"data": {
"my_error_data": "Error Message"
}
}
```
## ✍️ Authors
- [@antare74](https://github.com/antare74) - IDK
See also the list of [contributors](https://github.com/antare74) who participated in this project.
## 🎉 Acknowledgements
- Find on Packagist: https://packagist.org/packages/antare74/response-formatter
- References format: https://github.com/belajarkoding/laravel-response-formatter/blob/master/ResponseFormatter.php