PHPackages                             switon/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. switon/http-client

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

switon/http-client
==================

HTTP client contract with JSON-first helpers, typed failures, and pooled engines for Switon Framework

v1.0.0(1mo ago)021MITPHPPHP &gt;=8.3CI passing

Since Jun 6Pushed 2mo agoCompare

[ Source](https://github.com/switon-php/http-client)[ Packagist](https://packagist.org/packages/switon/http-client)[ Docs](https://github.com/switon-php/http-client)[ RSS](/packages/switon-http-client/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (8)Versions (2)Used By (1)

Switon HTTP Client Package
==========================

[](#switon-http-client-package)

[![CI](https://camo.githubusercontent.com/5c617a6bcd37ecee88dac899ca2331e8273bd2415e894251c17b3b47edfc374d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f737769746f6e2d7068702f687474702d636c69656e742f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/switon-php/http-client/actions/workflows/ci.yml) [![PHP 8.3+](https://camo.githubusercontent.com/c03f51341eebaefabbf137e291b20523fc74b4ffd084406d88524d266d95085d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d373737424234)](https://www.php.net/)

Switon's JSON-first HTTP client for application services that need typed failures, lifecycle events, pooled host reuse, and response helpers.

Highlights
----------

[](#highlights)

- **Pooled host reuse:** repeated calls to the same host reuse the same pooled engine setup.
- **Single client entrypoint:** `HttpClientInterface` gives app services one injectable HTTP client.
- **JSON-friendly defaults:** shortcut methods and response parsing fit API-style calls.
- **Raw request support:** non-JSON requests can still use the same client path.
- **Layered failures:** transport, status, and parsing errors are separated.
- **Request tuning:** timeout, proxy, TLS, CA, and pool size settings are centralized.
- **Lifecycle visibility:** request activity is exposed through client events.

Installation
------------

[](#installation)

```
composer require switon/http-client
```

Quick Start
-----------

[](#quick-start)

```
use Switon\Core\Attribute\Autowired;
use Switon\HttpClient\HttpClientInterface;

class UserService
{
    #[Autowired] protected HttpClientInterface $httpClient;

    public function createUser(array $data): array
    {
        return $this->httpClient
            ->post('https://api.example.com/users', $data)
            ->json();
    }
}
```

Docs:

License
-------

[](#license)

MIT.

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance87

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc0f20ad15b0ae9fbf9c6e2cd3008692b0c88a877ec8d3e0119211314bf86fc8?d=identicon)[switon](/maintainers/switon)

---

Top Contributors

[![switon-php](https://avatars.githubusercontent.com/u/247358032?v=4)](https://github.com/switon-php "switon-php (6 commits)")

---

Tags

http-clientjsonrequestsswitonhttpclientrequestsswiton

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[swlib/saber

Swoole coroutine HTTP client

973150.1k31](/packages/swlib-saber)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.8k11](/packages/sunrise-http-router)[khr/php-mcurl-client

wrap curl client (http client) for PHP 5.3; using php multi curl, parallel request and write asynchronous code

71230.4k6](/packages/khr-php-mcurl-client)

PHPackages © 2026

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