fyre / response
A HTTP response library.
v3.0.7
2024-10-30 11:30 UTC
Requires
- fyre/header: ^2.0
- fyre/message: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- fyre/php-cs-fixer-config: ^1.0
- phpunit/phpunit: ^11
README
FyreResponse is a free, open-source immutable HTTP response library for PHP.
Table Of Contents
Installation
Using Composer
composer require fyre/response
In PHP:
use Fyre\Http\Response;
Basic Usage
$options
is an array containing the message options.body
is a string representing the message body, and will default to "".headers
is an array containing headers to set, and will default to [].protocolVersion
is a string representing the protocol version, and will default to "1.1".statusCode
is a number representing the status code, and will default to 200.
$response = new Response($options);
Methods
This class extends the Message class.
Get Reason
Get the response reason phrase.
$reason = $response->getReason();
Get Status Code
Get the status code.
$code = $response->getStatusCode();
Set Status Code
Set the status code.
$code
is a number representing the status code.
$newResponse = $response->setStatusCode($code);