PHP code example of exbico / jsend-response
1. Go to this page and download the library: Download exbico/jsend-response library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
exbico / jsend-response example snippets
$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;
{"status":"error","message":"the message","version":"v1","data":{"id":1,"name":"User"}}