https://github.com/elusivecodes/fyremessage
FyreMessage is a free, open-source HTTP message library for PHP.
https://github.com/elusivecodes/fyremessage
http message php
Last synced: 9 months ago
JSON representation
FyreMessage is a free, open-source HTTP message library for PHP.
- Host: GitHub
- URL: https://github.com/elusivecodes/fyremessage
- Owner: elusivecodes
- License: mit
- Created: 2021-12-07T10:05:49.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T12:41:48.000Z (over 1 year ago)
- Last Synced: 2024-10-28T15:45:37.125Z (over 1 year ago)
- Topics: http, message, php
- Language: PHP
- Homepage:
- Size: 115 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FyreMessage
**FyreMessage** is a free, open-souce immutable HTTP message library for *PHP*.
## Table Of Contents
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
## Installation
**Using Composer**
```
composer require fyre/message
```
In PHP:
```php
use Fyre\Http\Message;
```
## 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*".
```php
$message = new Message($options);
```
## Methods
**Append Body**
Append data to the message body.
- `$data` is a string representing the data to append.
```php
$newMessage = $message->appendBody($data);
```
**Append Header**
Append a value to a message [*Header*](https://github.com/elusivecodes/FyreHeader).
- `$name` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) name.
- `$value` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) value.
```php
$newMessage = $message->appendHeader($name, $value);
```
**Get Body**
Get the message body.
```php
$body = $message->getBody();
```
**Get Header**
Get a message [*Header*](https://github.com/elusivecodes/FyreHeader).
- `$name` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) name.
```php
$header = $message->getHeader($name);
```
**Get Headers**
Get the message headers.
```php
$headers = $message->getHeaders();
```
**Get Header Value**
Get a message [*Header*](https://github.com/elusivecodes/FyreHeader) value.
- `$name` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) name.
```php
$value = $message->getHeaderValue($name);
```
**Get Protocol Version**
Get the protocol version.
```php
$version = $message->getProtocolVersion();
```
**Has Header**
Determine whether the message has a [*Header*](https://github.com/elusivecodes/FyreHeader).
- `$name` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) name.
```php
$hasHeader = $message->hasHeader($name);
```
**Prepend Header**
Prepend a value to a message [*Header*](https://github.com/elusivecodes/FyreHeader).
- `$name` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) name.
- `$value` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) value.
```php
$newMessage = $message->prependHeader($name, $value);
```
**Remove Header**
Remove a [*Header*](https://github.com/elusivecodes/FyreHeader).
- `$name` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) name.
```php
$newMessage = $message->removeHeader($name);
```
**Set Body**
Set the message body.
- `$data` is a string representing the message body.
```php
$newMessage = $message->setBody($data);
```
**Set Header**
Set a message [*Header*](https://github.com/elusivecodes/FyreHeader).
- `$name` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) name.
- `$value` is a string representing the [*Header*](https://github.com/elusivecodes/FyreHeader) value.
```php
$newMessage = $message->setHeader($name, $value);
```
**Set Protocol Version**
Set the protocol version.
- `$version` is a string representing the protocol version.
```php
$newMessage = $message->setProtocolVersion($version);
```