cherry-project / response
Cherry-project Response class
Installs: 74
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/cherry-project/response
Requires
- php: >=5.6.0
This package is auto-updated.
Last update: 2025-09-29 02:14:35 UTC
README
The Cherry-project Response wrapper
Including
Install from composer composer require cherry-project/response
Include Autoloader in your main file (Ex.: index.php)
require_once __DIR__ . '/vendor/autoload.php';
Class Request
Import class
use Cherry\HttpUtils\Response;
Crete class new object
$response = new Response();
Prepare data for transmission (Ex.: Array)
$arr = [ 'test' => 'vTest', 'test2' => [ 'test2.1' => '2.1', 'test2.2' => [ 'test2.2.1' => '2.2.1' ] ] ];
For sending response use sendResponse() method
The method takes 3 arguments:
- Content (Required; Mixed) - The data for returning;
- Status Code (Optional; 200 by default; Integer) - The HTTP Status Code;
- HTTP Headers (Optional; empty by default; Key
=>
Value Array) - The HTTP Headers;
echo $response->sendResponse(json_encode($arr), 200, ['Content-Type' => 'application/json']);
2019 © Cherry-project