Search by

solophp / http-client

Vitaliy Olos

Immutable PSR-18 HTTP client built on Guzzle: fluent API, safe retries, origin-bound credentials and redacted logs.

Package info

github.com/SoloPHP/HTTP-Client

pkg:composer/solophp/http-client

Statistics

Installs: 147

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 1

v5.0.0-RC1 2026-11-01 22:39 UTC

This package is auto-updated.

Last update: 2026-11-01 22:42:19 UTC


README

Latest Version on Packagist PHP Version License

Immutable PSR-18 HTTP client for PHP, built on Guzzle. Every configuration call returns a new client, so one instance can be shared safely; credentials go only to the origin of the base URI; retries are opt-in and never repeat a POST the server may have processed; files are attached only through explicit File objects; and query values, URI credentials and registered secrets are masked in logs and exception messages.

Installation

composer require solophp/http-client

Requires PHP 8.1+ and Guzzle 7.15.2+.

Example

use Solo\HttpClient\HttpClient;

$api = HttpClient::create('https://api.example.com/v1/')
    ->timeout(10)
    ->withToken($token)  // sent to https://api.example.com only
    ->retry(3, 500);     // off unless you ask for it

$response = $api->get('users', ['query' => ['page' => 2]]);

if ($response->successful()) {
    $users = $response->json('data'); // null when the body is not valid JSON
}

$api->post('users', ['json' => ['name' => 'Ada', 'email' => 'ada@example.com']]);

HTTP error statuses come back as responses; a failed transfer throws a PSR-18 exception. Every request method has an async variant, and sendRequest() serves code that depends on Psr\Http\Client\ClientInterface.

Documentation

Full Documentation

License

MIT. See LICENSE.