Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/junker/jsendresponse
JSendResponse Component for HttpFoundation based frameworks (Symfony, Silex, Drupal etc.)
https://github.com/junker/jsendresponse
httpfoundation jsend laravel php silex symfony
Last synced: 20 days ago
JSON representation
JSendResponse Component for HttpFoundation based frameworks (Symfony, Silex, Drupal etc.)
- Host: GitHub
- URL: https://github.com/junker/jsendresponse
- Owner: Junker
- License: mit
- Created: 2016-06-03T11:35:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-02-19T04:04:43.000Z (over 2 years ago)
- Last Synced: 2024-10-06T23:45:23.945Z (about 1 month ago)
- Topics: httpfoundation, jsend, laravel, php, silex, symfony
- Language: PHP
- Size: 18.6 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JSendResponse
JSendResponse Component for HttpFoundation based frameworks (Symfony, Silex, Laravel etc.)## Installation
The best way to install JSendResponse is to use a [Composer](https://getcomposer.org/download):php composer.phar require junker/symfony-jsend-response
## Examples
```php
use Junker\JsendResponse\JSendResponse;
use Junker\JsendResponse\JSendSuccessResponse;
use Junker\JsendResponse\JSendFailResponse;
use Junker\JsendResponse\JSendErrorResponse;class AppController
{
...$data = ['id' => 50, 'name' => 'Waldemar'];
$message = 'Error, total error!';
$code = 5;return new JsendResponse(JSendResponse::STATUS_SUCCESS, $data);
#or
return new JsendResponse(JSendResponse::STATUS_FAIL, $data);
#or
return new JsendResponse(JSendResponse::STATUS_ERROR, NULL, $message);
#or
return new JsendResponse(JSendResponse::STATUS_ERROR, $data, $message, $code);
#or
return new JsendSuccessResponse($data);
#or
return new JsendFailResponse($data);
#or
return new JsendErrorResponse($message);
#or
return new JsendErrorResponse($message, $code, $data);}
```