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
Requires
- fyre/stream: ^4.0
- psr/http-message: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.59
- fyre/php-cs-fixer-config: ^1.0
- phpunit/phpunit: ^12
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
$optionsis an array containing the message options.bodyis a string or StreamInterface representing the message body, and will default to "".headersis an array containing headers to set, and will default to [].protocolVersionis 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.
$nameis a string representing the header name.
$values = $message->getHeader($name);
Get Header Line
Get the value string of a message header.
$nameis 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.
$nameis a string representing the header name.
$hasHeader = $message->hasHeader($name);
With Added Header
Clone the Message with new value(s) added to a header.
$nameis a string representing the header name.$valueis a string or array representing the header value.
$newMessage = $message->withAddedHeader($name, $value);
With Body
Clone the Message with a new body.
$streamis a StreamInterface representing the message body.
$newMessage = $message->withBody($stream);
With Header
Clone the Message with a new header.
$nameis a string representing the header name.$valueis a string or array representing the header value.
$newMessage = $message->withHeader($name, $value);
Without Header
Clone the Message without a header.
$nameis a string representing the header name.
$newMessage = $message->withoutHeader($name);
With Protocol Version
Clone the Message with a new protocol version.
$versionis a string representing the protocol version.
$newMessage = $message->withProtocolVersion($version);