dev-master
9999999-dev https://github.com/vena/jsend4laravelSimply adds macros to Laravel 4's Response class for JSend-formatting responses.
MIT
The Requires
- php >=5.4.0
- illuminate/support 4.2.*
The Development Requires
by Daniel Vena
laravel jsend
Wallogit.com
2017 © Pedro Peláez
Simply adds macros to Laravel 4's Response class for JSend-formatting responses.
This is just a simple package to add a few macros to Laravel 4's
Response class and extend its json method for JSend-formatted responses., (*1)
Add the package in the require key of your composer.json:, (*2)
"vena/jsend4laravel": "dev-master"
Update composer to grab the package:, (*3)
composer update
Add the service provider to the end of your providers array in app/config/app.php:, (*4)
'providers' => array(
...
'Vena\JSend4Laravel\JSend4LaravelServiceProvider',
);
That's it, no further configuration is necessary., (*5)
All macros return a Response object, allowing you to override anything about the response
you require. Default HTTP status codes are included and everything eventually goes through
the Response::json() method to set the appropriate Content-Type header, but what you do
with the Response object is up to you., (*6)
Wrapper around Response::json(). The response will be sent as JSONP if a 'callback' value is specified in the request input., (*7)
It's not especially useful to call this by itself, as it will not format the data whatsoever. However, all other JSend4Laravel methods ultimate route through this, which then returns a jsonResponse., (*8)
$data: Data to include in the response, defaults to NULL.$httpStatus: HTTP status code for the response, defaults to 200.$headers: Response headers for the response. JSON responses are always sent
with Content-Type: application/jsonReturns: Response, (*9)
Formats a JSend success response with the supplied data. All parameters are optional., (*10)
$data: Data to include in the response, defaults to NULL.$httpStatus: HTTP status code for the response, defaults to 200.$headers: Response headers for the response.Returns: Response, (*11)
Formats a JSend fail response. All parameters are optional., (*12)
$data: Data to include in the response, defaults to NULL.$httpStatus: HTTP status code for the response, defaults to 400.$headers: Response headers for the response.Returns: Response, (*13)
Formats a JSend error response with the supplied data., (*14)
$message: Required. A meangingful, human-readable message explaining the error.All other parameters are optional:, (*15)
$code: A numeric reference code for the error, if applicable.$data: Additional error data to send with the request (stack traces, other
debug info). Not included in response if set to NULL (default).$httpStatus: HTTP status code for the response, defaults to 400.$headers: Response headers for the response.Returns: Response, (*16)
Simply adds macros to Laravel 4's Response class for JSend-formatting responses.
MIT
laravel jsend