https://github.com/elusivecodes/fyreresponse
FyreResponse is a free, open-source HTTP response library for PHP.
https://github.com/elusivecodes/fyreresponse
http message php response
Last synced: 2 months ago
JSON representation
FyreResponse is a free, open-source HTTP response library for PHP.
- Host: GitHub
- URL: https://github.com/elusivecodes/fyreresponse
- Owner: elusivecodes
- License: mit
- Created: 2021-12-08T08:55:40.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-27T12:45:58.000Z (about 1 year ago)
- Last Synced: 2024-10-27T14:22:53.971Z (about 1 year ago)
- Topics: http, message, php, response
- Language: PHP
- Homepage:
- Size: 85 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FyreResponse
**FyreResponse** is a free, open-source immutable HTTP response library for *PHP*.
## Table Of Contents
- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)
## Installation
**Using Composer**
```
composer require fyre/response
```
In PHP:
```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*.
```php
$response = new Response($options);
```
## Methods
This class extends the [*Message*](https://github.com/elusivecodes/FyreMessage) class.
**Get Reason**
Get the response reason phrase.
```php
$reason = $response->getReason();
```
**Get Status Code**
Get the status code.
```php
$code = $response->getStatusCode();
```
**Set Status Code**
Set the status code.
- `$code` is a number representing the status code.
```php
$newResponse = $response->setStatusCode($code);
```