fyre/request

A HTTP request library.

v3.0.6 2024-06-29 06:25 UTC

README

FyreRequest is a free, open-source immutable HTTP request library for PHP.

Table Of Contents

Installation

Using Composer

composer require fyre/request

In PHP:

use Fyre\Http\Request;

Request Creation

  • $uri is a Uri and will default to null.
  • $options is an array containing the message options.
    • method is a string representing the request method, and will default to "get".
    • 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".
$request = new Request($uri, $options);

Methods

This class extends the Message class.

Get Method

Get the request method.

$method = $request->getMethod();

Get Uri

Get the request URI.

$uri = $request->getUri();

This method will return a Uri.

Set Method

Set the request method.

  • $method is a string representing the request method.
$newRequest = $request->setMethod($method);

Set Uri

Set the request URI.

  • $uri is a Uri.
$newRequest = $request->setUri($uri);