junker/symfony-jsend-response

JSendResponse Component for HttpFoundation based applications (Symfony, Silex, Drupal etc.)

0.3.1 2021-07-16 14:21 UTC

This package is auto-updated.

Last update: 2024-09-19 09:17:43 UTC


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);

}