fyre/message

A HTTP message library.

Installs: 334

Dependents: 2

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/fyre/message

v4.0.2 2025-11-02 10:22 UTC

README

FyreMessage is a free, open-souce immutable HTTP message library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/message

In PHP:

use Fyre\Http\Message;

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".
$message = new Message($options);

Methods

Get Body

Get the message body.

$stream = $message->getBody();

Get Header

Get the values of message header.

  • $name is a string representing the header name.
$values = $message->getHeader($name);

Get Header Line

Get the value string of a message header.

  • $name is a string representing the header name.
$value = $message->getHeaderValue($name);

Get Headers

Get the message headers.

$headers = $message->getHeaders();

Get Protocol Version

Get the protocol version.

$version = $message->getProtocolVersion();

Has Header

Determine whether the message has a header.

  • $name is a string representing the header name.
$hasHeader = $message->hasHeader($name);

With Added Header

Clone the Message with new value(s) added to a header.

  • $name is a string representing the header name.
  • $value is a string or array representing the header value.
$newMessage = $message->withAddedHeader($name, $value);

With Body

Clone the Message with a new body.

  • $stream is a StreamInterface representing the message body.
$newMessage = $message->withBody($stream);

With Header

Clone the Message with a new header.

  • $name is a string representing the header name.
  • $value is a string or array representing the header value.
$newMessage = $message->withHeader($name, $value);

Without Header

Clone the Message without a header.

  • $name is a string representing the header name.
$newMessage = $message->withoutHeader($name);

With Protocol Version

Clone the Message with a new protocol version.

  • $version is a string representing the protocol version.
$newMessage = $message->withProtocolVersion($version);