iothost / phpresponse
Simple PHP class for handling HTTP response right way.
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/iothost/phpresponse
This package is not auto-updated.
Last update: 2025-09-28 02:05:24 UTC
README
##iothost/phpresponse
Simple PHP class to handle responses correctly.
####Installation
composer require iothost/phpresponse
####Example usage
$loader = require './vendor/autoload.php';
$response = new \Iothost\PhpResponse\Response();
// add header
$response->addHeader('Cache-Control: no-cache');
// set Content-Type, can be entered as a string
$response->addHeader($response::CT_TEXT);
// set HTTP status code, can be entered as a number (int)
$response->setStatus($response::STATUS_OK);
// set response body as a string
$response->setBody($string);
// OR
// set response body as JSON (from array)
$response->setBodyJson($array);
// send response
$response->send();