Switon's JSON-first HTTP client for application services that need typed failures, lifecycle events, pooled host reuse, and response helpers.
- Pooled host reuse: repeated calls to the same host reuse the same pooled engine setup.
- Single client entrypoint:
HttpClientInterfacegives 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.
composer require switon/http-clientuse 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: https://docs.switon.dev/latest/http-client
MIT.