PHP code example of tan-sandbox / json-rest

1. Go to this page and download the library: Download tan-sandbox/json-rest 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/ */

    

tan-sandbox / json-rest example snippets


use TanSandbox\JsonRest\Builder;
$builder = new Builder() ;

$data = array (
    'name' => 'Nithin',
    'subject' => 'English',
    'mark' => '90'
);
$builder->ok()->send($data) ;

$data = array(
    'name' => 'Please provide a valid name'
);
$builder->fail()->send($data) ;

$data = array(
    'reply' => 'Resource not found.'
);
$builder->setStatus(404)->send($data) ;

$data = array (
    'name' => 'Nithin',
    'subject' => 'English',
    'mark' => '90'
);
$builder->setMessage('Action completed')->setStatus(200)->send($data) ;

$builder->setName('Nithin')
    ->setSubject('English')
    ->setMark('90')
    ->setCustomNotes('Student of ZF2')
    ->sendie() ;
sh
$ php composer.phar install