fyre/response

A HTTP response library.

v3.0.2 2024-06-01 14:35 UTC

This package is auto-updated.

Last update: 2024-06-01 14:35:30 UTC


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;

Response Creation

  • $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);