junker / symfony-jsend-response
JSendResponse Component for HttpFoundation based applications (Symfony, Silex, Drupal etc.)
Installs: 15 716
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 3
Open Issues: 0
Requires
- php: ^7.2 || ^8.0
- ext-json: *
- symfony/http-foundation: ^2.0 || ^3.0 || ^4.0 || ^5.0
README
JSendResponse Component for HttpFoundation based frameworks (Symfony, Silex, Laravel etc.)
Installation
The best way to install JSendResponse is to use a Composer:
php composer.phar require junker/symfony-jsend-response
Examples
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); }