fyre/response

A HTTP response library.

Installs: 288

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/fyre/response

v4.0.2 2025-11-02 10:31 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 or StreamInterface 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.
    • reasonPhrase is a string representing the reason phrase, and will default to "".
$response = new Response($options);

If a reasonPhrase is not provided, the default reason for the status code will be used instead.

Methods

This class extends the Message class.

Get Reason Phrase

Get the response reason phrase.

$reason = $response->getReasonPhrase();

Get Status Code

Get the status code.

$code = $response->getStatusCode();

With Status

Set the status code.

  • $code is a number representing the status code.
  • $reasonPhrase is a string representing the reason phrase, and will default to "".
$newResponse = $response->withStatus($code, $reasonPhrase);

If a $reasonPhrase is not provided, the default reason for the status code will be used instead.