PHP code example of evandarwin / jsend
1. Go to this page and download the library: Download evandarwin/jsend 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/ */
evandarwin / jsend example snippets
use EvanDarwin\JSend\JSendBuilder;
$builder = new JSendBuilder();
// This will return a JSendResponse
$response = $builder->success()
->data(['id' => 3])
->code(12)
->message("Hello")
->get();
// Output the JSON
header('Content-Type: application/json');
echo $response->getResponse();
use EvanDarwin\JSend\JSendBuilder;
// These alternatives statuses can be set like so
$builder = new JSendBuilder();
// For failure
$builder->failed()->get();
// For error
$builder->error()->get();