Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit 7cbc645

Browse files
author
Andrey Helldar
committed
Updated README.md
1 parent 17e6881 commit 7cbc645

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Instead, you may of course manually update your require block and run `composer
7070

7171
Alright! Use `api_response()` helper.
7272

73+
[[ to top ]](#api-response)
74+
7375

7476
## Using
7577

@@ -84,6 +86,8 @@ return with code 304:
8486
}
8587
```
8688

89+
[[ to top ]](#api-response)
90+
8791
### as integer with default code:
8892
```php
8993
return api_response(304);
@@ -95,6 +99,8 @@ return with code 200:
9599
}
96100
```
97101

102+
[[ to top ]](#api-response)
103+
98104
### as string with default code:
99105
```php
100106
return api_response('qwerty');
@@ -106,6 +112,8 @@ return with code 200:
106112
}
107113
```
108114

115+
[[ to top ]](#api-response)
116+
109117
### as string with code:
110118
```php
111119
return api_response('qwerty', 400);
@@ -120,6 +128,8 @@ return with code 400:
120128
}
121129
```
122130

131+
[[ to top ]](#api-response)
132+
123133
### as integer with code:
124134
```php
125135
return api_response(304, 400);
@@ -134,6 +144,8 @@ return with code 400:
134144
}
135145
```
136146

147+
[[ to top ]](#api-response)
148+
137149
### as array:
138150
```php
139151
$data = [
@@ -148,6 +160,8 @@ $data = [
148160
];
149161
```
150162

163+
[[ to top ]](#api-response)
164+
151165
#### as error
152166
```php
153167
return api_response($data, 400);
@@ -171,6 +185,8 @@ return with code 400:
171185
}
172186
```
173187

188+
[[ to top ]](#api-response)
189+
174190
#### as success
175191
```php
176192
return api_response($data, 200);
@@ -193,6 +209,8 @@ return with code 200:
193209

194210
If the first parameter is a number, then the decryption of the error by code will be return. In other cases, the value of the passed variable will be return.
195211

212+
[[ to top ]](#api-response)
213+
196214
### with additional content
197215
```php
198216
return api_response('title', 200, [], ['foo' => 'bar']);
@@ -240,6 +258,8 @@ return with code 400:
240258
}
241259
```
242260

261+
[[ to top ]](#api-response)
262+
243263

244264
## Use without `data` key
245265

@@ -268,6 +288,8 @@ return with code 304:
268288
{}
269289
```
270290

291+
[[ to top ]](#api-response)
292+
271293
### as integer with default code and without `data` key:
272294
```php
273295
return api_response(304);
@@ -277,6 +299,8 @@ return with code 200:
277299
304
278300
```
279301

302+
[[ to top ]](#api-response)
303+
280304
### as string with default code and without `data` key:
281305
```php
282306
return api_response('qwerty');
@@ -286,6 +310,8 @@ return with code 200:
286310
"qwerty"
287311
```
288312

313+
[[ to top ]](#api-response)
314+
289315
### as string with code and without `data` key:
290316
```php
291317
return api_response('qwerty', 400);
@@ -300,6 +326,8 @@ return with code 400:
300326
}
301327
```
302328

329+
[[ to top ]](#api-response)
330+
303331
### as integer with code and without `data` key:
304332
```php
305333
return api_response(304, 400);
@@ -314,6 +342,8 @@ return with code 400:
314342
}
315343
```
316344

345+
[[ to top ]](#api-response)
346+
317347
### as array and without `data` key:
318348
```php
319349
$data = [
@@ -328,6 +358,8 @@ $data = [
328358
];
329359
```
330360

361+
[[ to top ]](#api-response)
362+
331363
#### as error and without `data` key
332364
```php
333365
return api_response($data, 400);
@@ -351,6 +383,8 @@ return with code 400:
351383
}
352384
```
353385

386+
[[ to top ]](#api-response)
387+
354388
#### as success and without `data` key
355389
```php
356390
return api_response($data, 200);
@@ -371,6 +405,8 @@ return with code 200:
371405

372406
If the first parameter is a number, then the decryption of the error by code will be return. In other cases, the value of the passed variable will be return.
373407

408+
[[ to top ]](#api-response)
409+
374410
### with additional content and without `data` key:
375411
```php
376412
return api_response('title', 200, [], ['foo' => 'bar']);
@@ -418,6 +454,8 @@ return with code 400:
418454
}
419455
```
420456

457+
[[ to top ]](#api-response)
458+
421459

422460
### Using in Laravel 5+ framework
423461

@@ -449,7 +487,11 @@ class Handler extends ExceptionHandler
449487
}
450488
```
451489

490+
[[ to top ]](#api-response)
491+
452492

453493
## Copyright and License
454494

455495
`API Response` was written by Andrey Helldar, and is licensed under the [MIT License](LICENSE).
496+
497+
[[ to top ]](#api-response)

0 commit comments

Comments
 (0)