Skip to content

Commit e1b6d90

Browse files
committed
Readme toegevoegd
1 parent 9dae01e commit e1b6d90

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<a href="http://firebit.nl/">
2+
<p align="center">
3+
<img src="https://avatars2.githubusercontent.com/u/49287371?s=200&v=4](https://avatars2.githubusercontent.com/u/49287371?s=200&v=4)" height="100px" alt="Firebit logo"/>
4+
</p>
5+
</a>
6+
7+
# Laravel API Response
8+
This package aims to makes responses from the API consistent and easy to use. It is compliant with the HTTP standard and the JSend standard.
9+
10+
## Example
11+
#### Code
12+
```php
13+
function getUser($id){
14+
// Get the data we wish to return
15+
$user = User:find($id);
16+
17+
// If the user does not exist we return an error
18+
if(!$user){
19+
return ApiResponseFactory::notFound("User does not exist");
20+
}
21+
22+
// Return the data by using a ReponseFactory
23+
return ApiResponseFactory::success($user);
24+
}
25+
```
26+
27+
#### Error output
28+
```json
29+
{
30+
"status":"fail",
31+
"message":"User does not exist"
32+
}
33+
```
34+
35+
#### Success output
36+
```json
37+
{
38+
"status":"success",
39+
"data": {
40+
"id":1,
41+
"name":"John Doe",
42+
"email":"[email protected]",
43+
"created_at":null,
44+
"updated_at":null
45+
}
46+
}
47+
```
48+
49+
50+
## Installation
51+
To install you can use Composer, use the following command to install this package. <br/>
52+
`` composer require firebit/laravel-api-response``
53+
54+
## Documentation
55+
Coming soon!
56+
57+
## Progress
58+
- [X] JSend compliance
59+
- [ ] PHPUnit tests
60+
- [ ] Documentation
61+
62+
## License
63+
For the license please check the LICENSE file, this project has the MIT license.

0 commit comments

Comments
 (0)