fyre / request
A HTTP request library.
Installs: 294
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
pkg:composer/fyre/request
Requires
- fyre/message: ^4.0
- fyre/uri: ^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
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;
Basic Usage
$uriis a string or UriInterface and will default to null.$optionsis an array containing the message options.methodis a string representing the request method, and will default to "get".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".
$request = new Request($uri, $options);
Methods
This class extends the Message class.
Get Method
Get the request method.
$method = $request->getMethod();
Get Request Target
Get the request target.
$requestTarget = $request->getRequestTarget();
Get Uri
Get the request URI.
$uri = $request->getUri();
With Method
Clone the Request with a new method.
$methodis a string representing the request method.
$newRequest = $request->withMethod($method);
With Request Target
Clone the Request with a new request target.
$requestTargetis a string representing the request target.
$newRequest = $request->withRequestTarget($requestTarget);
With Uri
Clone the Request with a new URI.
$uriis a UriInterface.$preserveHostis a boolean indicating whether to preserve the host header, and will default to false.
$newRequest = $request->withUri($uri, $preserveHost);