exbico/jsend-response

JSend implementation in php

2.0.1 2020-05-28 11:41 UTC

This package is auto-updated.

Last update: 2024-05-09 09:06:23 UTC


README

#Library for JSend

You can find out more information about JSend here.

How to use

$response = new Response();
$response->setMessage('the message');
$response->setStatus(Response::ERROR);

$data = ['id' => 1];
$response->setData($data);

$newData = ['name' => 'User'];
$response->addData($newData);

$response->setVersion('v1');

echo $response;

When you print out your object, you'll get something like this:

{"status":"error","message":"the message","version":"v1","data":{"id":1,"name":"User"}}