fyre/response

A HTTP response library.

v3.0.7 2024-10-30 11:30 UTC

This package is auto-updated.

Last update: 2024-10-30 11:30:32 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;

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