Download the PHP package harmonyio/http-client without Composer
On this page you can find all versions of the php package harmonyio/http-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package http-client
Http-Client
Async caching aware http client
Requirements
- PHP 7.3
- Redis (if wanting to use the Redis caching provider)
In addition for non-blocking context one of the following event libraries should be installed:
Installation
Usage
Caching requests
The following example shows how to make a request and cache the result so consecutive calls will used the cached results instead of making a new external HTTP call.
Non-caching requests
It is also possible to make non-caching requests.
Client interface
The HTTP client's interface only contains a single method: Client::request(\HarmonyIO\HttpClient\Message\Request $request)
.
The $request
parameter can be either a "normal" non-caching request (HarmonyIO\HttpClient\Message\Request
) or a caching request (HarmonyIO\HttpClient\Message\CachingRequest
).
HarmonyIO\HttpClient\Message\Request
The constructor of the request class expects at least a URL to make the request to and optionally an HTTP method (defaults to GET).
Optional request parts can be set in setter method of the request class:
HarmonyIO\HttpClient\Message\CachingRequest
The constructor of the caching request class expects at least a key, a TTL, the URL to make the request to and optionally an HTTP method (defaults to GET).
Optional request parts can be set in setter method of the request class as defined in the previous section.
All versions of http-client with dependencies
ext-json Version *
amphp/amp Version ^2.1.1
amphp/artax Version ^3.0.14
harmonyio/cache Version ^1.0.0-rc1