sujal / json-resp
A class that returns formatted JSON response with HTTP status
dev-master
2020-08-15 20:59 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2025-07-16 23:36:06 UTC
README
Class that returns formatted JSON response with HTTP status
Installation
composer require sujal/json-resp
Usage
<?php require "vendor/autoload.php"; use Demo\ResponseClass\JsonResponse; $student= [ 'name' => 'John Doe', 'course' => 'Software Engineering', 'level' => '200', 'collections' => [ 'books' => 'Intro to UML', 'music' => 'rap' ] ]; new JsonResponse('ok', '', $student); ?>
Param 1 (Required)
- success or ok - 200 http status
- unauthorized - 401 http status
- 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