🦖
[■] codesaur/http-client 1=[↕]
codesaur/http-client · v2.1.2

HTTP Client

Lightweight client component for sending HTTP requests and building/sending MIME email

Packagist version Downloads PHP version License Aikido Intel 99/100
1:1 ══ composer require codesaur/http-client
[■] HTTP Client

Four core classes: CurlClient (flexible cURL-based HTTP client), JSONClient (for JSON REST APIs), Response (status code, headers, body as an object) and Mail (MIME email sender with HTML + Text + multiple attachments). Full UTF-8 support throughout.

Features
  • CurlClient - request(), send(), upload(), sendWithRetry(), debug mode
  • JSONClient - get / post / put / patch / delete with base URL support
  • Response - statusCode, getHeader(), json() decode
  • Mail - HTML + Text, file and URL attachments, UTF-8 names/subjects
  • Pass through curl options such as forcing HTTP/1.1
  • Requires only ext-curl and ext-json

Core classes

ClassPurpose
CurlClientFlexible HTTP client based on cURL
JSONClientClient for JSON REST APIs
ResponseHTTP response object (status code, headers, body)
MailMIME email sender with HTML + Text + multiple attachments

Quick example

use codesaur\Http\Client\JSONClient;
use codesaur\Http\Client\Mail;

// JSON API-тэй ажиллах / Work with a JSON API
$api = new JSONClient('https://api.example.com/v1');
$users = $api->get('/users', ['page' => 1]);
$created = $api->post('/users', ['name' => 'codesaur'], ['Authorization' => 'Bearer token']);

// MIME имэйл илгээх / Send a MIME email
$mail = new Mail();
$mail->targetTo('user@example.com', 'Хэрэглэгч');
$mail->setFrom('no-reply@example.com', 'codesaur');
$mail->setSubject('Сайн байна уу?');
$mail->setMessage('<h1>Hello!</h1><p>Тест имэйл.</p>');
$mail->addFileAttachment(__DIR__ . '/file.pdf');
$mail->sendMail();

Running tests

composer test
[■] Info
Install
composer require codesaur/http-client
Requirements
  • PHP 8.2.1+
  • ext-curl
  • ext-json
  • Composer
Aikido score 99/100
Checked: 2026-09-10
Links