mikes / json-response
A simple class that returns JSON response with HTTP status
1.1.1
2022-06-24 10:33 UTC
Requires
- php: >=5.3.0
This package is auto-updated.
Last update: 2025-05-24 17:12:38 UTC
README
A simple class that returns a formatted json response
Installation
composer require mikes/json-response
<?php require __DIR__ . "/vendor/autoload.php"; use mikesjsonresponse\ResponseClass\JsonResponse; $student = array( 'name' => 'John Smith', 'course' => 'Maths', 'level' => '101', 'collections' => ['books' => 'Intro to UML', 'music' => 'rap'] ); new JsonResponse('unauthorized', '', $student);
Param 1 (required)
- success or ok - 200 http status
- unauthorizsed - 401 http status
- exception - 500 http status
Param 2 (optional)
string - the return message, leave empty if not available
param 3 (optional)
array - an array of data