PHPackages                             sofa/http-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. sofa/http-client

ActiveLibrary[HTTP &amp; Networking](/categories/http)

sofa/http-client
================

Factory wrapper around Guzzle HTTP Client to simplify things for lazy dev

v1.2.0(1y ago)0118.1k↓26.8%3[1 issues](https://github.com/jarektkaczyk/http-client/issues)MITPHPPHP &gt;=7.4CI passing

Since May 5Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/jarektkaczyk/http-client)[ Packagist](https://packagist.org/packages/sofa/http-client)[ Fund](https://softonsofa.com)[ GitHub Sponsors](https://github.com/jarektkaczyk)[ RSS](/packages/sofa-http-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (12)Used By (0)

http-client
===========

[](#http-client)

Wrapper around Guzzle HTTP Client to simplify bootstrapping

[![Latest Version on Packagist](https://camo.githubusercontent.com/045f3fb7860287100f8ca1763af1576a8a5f858030cd324dabc10fa70c438b0b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f66612f687474702d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jarektkaczyk/http-client)[![GitHub Tests Action Status](https://github.com/jarektkaczyk/http-client/workflows/Tests/badge.svg)](https://github.com/jarektkaczyk/http-client/actions?query=workflow%3Atests+branch%3Amaster)[![Total Downloads](https://camo.githubusercontent.com/15e0f995eb1a5b1c1c7f1c2fe6519b0c6f695c9056708eb3d891bc7fb2d43875/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f736f66612f687474702d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/jarektkaczyk/http-client)

The simplest example in a Laravel app - ready to copy-paste and run

```
use Sofa\HttpClient\Factory;

// register factory in IoC with default app logger
app()->bind(Factory::class, fn () => new Factory(app()->environment('testing'), app('log')->driver()));

// then inject or resolve wherever you need
$httpClient = app(Factory::class)
  ->withOptions(['base_uri' => 'https://api.github.com'])
  ->enableRetries()
  ->enableLogging()
  ->make();

$httpClient->get('users/jarektkaczyk');

// et voila! Automatic retries in case of server errors and logging out of the box:
[2020-05-22 12:38:32] local.INFO: GET https://api.github.com/users/jarektkaczyk HTTP/1.1 200 (1351 application/json; charset=utf-8) {"request": , "response": {
  "login": "jarektkaczyk",
  "blog": "https://softonsofa.com",
  "location": "Singapore",
  ...
  }
}
```

Raw example with more customization:

```
// Raw example
$logger = new Logger('HttpLogger');
$logger->pushHandler(
  new StreamHandler('/path/to/the/log/' . date('Y-m-d') . '.log'))
);

$clientFactory = new Factory($fakeRequests, $logger);
$httpClient = $clientFactory
  ->withOptions([
    'base_uri' => 'https://api.github.com',
    'headers' => [
      'User-Agent' => 'My Awesome Client',
    ],
  ])
  ->enableRetries($retries = 3, $delayInSec = 1, $minStatus = 500)
  ->enableLogging($customLogFormat)
  ->withMiddleware($customGuzzleMiddleware)
  ->make();
```

Testing
-------

[](#testing)

Guzzle on its own offers [testing facilities](http://docs.guzzlephp.org/en/stable/testing.html) but here we made it even easier. Just so you don't have to worry about setting up custom testing clients or dropping `if`s here and there:

```
$factory = new Factory(true, $logger);
$httpClient = $factory->enableLogging()->make();
$httpClient->get('https://api.github.com/users/jarektkaczyk');
$httpClient->get('https://api.github.com/users/octokit');

$factory->getHistory($httpClient);
=>
[
 [
   "request" => GuzzleHttp\Psr7\Request {#7218},
   "response" => GuzzleHttp\Psr7\Response {#7225},
   "error" => null,
   "options" => [
     "synchronous" => true,
     "handler" => GuzzleHttp\HandlerStack {#7205},
     "allow_redirects" => [
       "max" => 5,
       "protocols" => [
         "http",
         "https",
       ],
       "strict" => false,
       "referer" => false,
       "track_redirects" => false,
     ],
     "http_errors" => true,
     "decode_content" => true,
     "verify" => true,
     "cookies" => false,
     "idn_conversion" => true,
   ],
 ],
 ...
```

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance47

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 89.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~250 days

Recently: every ~378 days

Total

8

Last Release

451d ago

PHP version history (3 changes)1.0PHP ^7.4

1.0.2PHP ^7.4|^8.0

v1.1PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/34d383bf50d6c73fc747d89a5efacd41ccecc9695aec04148a7c04fc00ef26e7?d=identicon)[jarektkaczyk](/maintainers/jarektkaczyk)

---

Top Contributors

[![jarektkaczyk](https://avatars.githubusercontent.com/u/6928818?v=4)](https://github.com/jarektkaczyk "jarektkaczyk (17 commits)")[![IonBazan](https://avatars.githubusercontent.com/u/1985514?v=4)](https://github.com/IonBazan "IonBazan (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sofa-http-client/health.svg)

```
[![Health](https://phpackages.com/badges/sofa-http-client/health.svg)](https://phpackages.com/packages/sofa-http-client)
```

###  Alternatives

[shopify/shopify-api

Shopify API Library for PHP

4634.8M16](/packages/shopify-shopify-api)[akamai-open/edgegrid-client

Implements the Akamai {OPEN} EdgeGrid Authentication specified by https://developer.akamai.com/introduction/Client\_Auth.html

482.5M6](/packages/akamai-open-edgegrid-client)[api-platform/metadata

API Resource-oriented metadata attributes and factories

243.5M96](/packages/api-platform-metadata)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[mimmi20/browser-detector

Library to detect Browsers and Devices

48153.5k3](/packages/mimmi20-browser-detector)[discord-php/http

Handles HTTP requests to Discord servers

25318.7k8](/packages/discord-php-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
