PHP Classes
elePHPant
Icontem

PHP JSON Response Class: Generate a HTTP request response in JSON format

Recommend this page to a friend!

  Author Author  
Name: Ogbemudia Osayawe <contact>
Classes: 3 packages by
Country: Malaysia Malaysia


  Detailed description   Download Download .zip .tar.gz  
This class can generate a HTTP request response in JSON format.

It can take an a variable value as parameter and generates a JSON encoded string from that value to serve it as response for the current request.

The class can also take the string for the request status value and serves the respective HTTP response header being 200 for ok, 401 for unauthorized and 500 for exception.

Details

json-response

A simple class that returns a properly formatted json response with HTTP status

Installation

composer require devscreencast/json-response

Usage

<?php
require_once __DIR__ ."/vendor/autoload.php";

use Devscreencast\ResponseClass\JsonResponse;

$student = array(
    'name' => 'John Doe',
    'course' => 'Software Engineering',
    'level' => '200',
    'collections' => ['books' => 'Intro to UML', 'music' => 'rap']
);

new JsonResponse('ok', '', $student);

Param 1 (Required)

  1. success or ok - 200 http status
  2. unauthorized - 401 http status
  3. exception - 500 http status (internal server error)

Param 2 (Optional)

string - the return message, use empty quote if not available

Param 3 (Optional)

Array - Array of Data


  Classes of Ogbemudia Osayawe  >  PHP JSON Response Class  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  

 

Name: PHP JSON Response Class
Base name: json-response
Description: Generate a HTTP request response in JSON format
Version: -
PHP version: 5
License: MIT/X Consortium License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image HTTP HTTP protocol clients, headers and cookies View top rated classes
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Read me

Download Download all files: json-response.tar.gz json-response.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.