Download the PHP package coenond/lrvl-rspns without Composer
On this page you can find all versions of the php package coenond/lrvl-rspns. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download coenond/lrvl-rspns
More information about coenond/lrvl-rspns
Files in coenond/lrvl-rspns
Package lrvl-rspns
Short Description A simple package for Laravel that helps you standardize your HTTP responses.
License MIT
Informations about the package lrvl-rspns
LRVL.RSPNS.
A simple helper package for Laravel that helps you standardize your HTTP responses.
The helper includes multiple functions that returns a Json Response. Each function is already defined with the correct HTTP Status code.
Simply add this package to your Laravel project by running:
composer require coenond/lrvl-rspns
Example Usage
The helper methodes can be used in controllers. For example in the User controller:
List of All helpers
-
rspns_ok()- Param
$datais optional - Returns status code
200
- Param
-
rspns_created()- Param
$datais optional - Returns status code
201
- Param
-
rspns_accepted()- Param
$datais optional - Returns status code
202
- Param
-
rspns_no_content()- Param
$datais optional - Returns status code
204
- Param
-
rspns_bad_request()- Param
$datais optional - Param
$messageis optional - Returns status code
400
- Param
-
rspns_unauthorized()- Param
$datais optional - Param
$messageis optional - Returns status code
401
- Param
-
rspns_not_found()- Param
$datais optional - Param
$messageis optional - Returns status code
404
- Param
-
rspns_method_not_allowed()- Param
$datais optional - Param
$messageis optional - Returns status code
405
- Param
-
rspns_internal_server_error()- Param
$datais optional - Param
$messageis optional - Returns status code
500
- Param
-
rspns_not_implemented()- Param
$datais optional - Param
$messageis optional - Returns status code
501
- Param
rspns_bad_gateway()- Param
$datais optional - Param
$messageis optional - Returns status code
502
- Param
Success Responses
The 2xx (success) responses are defined with the status success and has an optional data object.
Error Responses
The 4xx and 5xx responses are defined with the status success and has an optional data object and message parameter.
NOTE: Unfortunately, PHP doesn't support named parameters, so if you want to return an error message without data is should be return like: return rspns_bad_request(null, 'some messsage here');
Contribution is always welcome :)
I developed this package as a 'scratch my own itch' solution. Feel free to open a Pull Request for message me for any suggestions.
:beer: Cheers!