mini\Http\Client\HttpClient
class
Documentation
PSR-18 compliant HTTP client built on curl
Usage:
$client = new HttpClient();
// PSR-18: Send a PSR-7 request
$request = new Request('GET', 'https://api.example.com/users');
$response = $client->sendRequest($request);
// Convenience methods
$response = $client->get('https://api.example.com/users');
$response = $client->post('https://api.example.com/users', ['name' => 'John']);
$response = $client->postJson('https://api.example.com/users', ['name' => 'John']);
// With options
$client = new HttpClient([
'timeout' => 30,
'verify_ssl' => true,
'follow_redirects' => true,
'max_redirects' => 5,
]);
Inheritance
Implements:
Psr\Http\Client\ClientInterface
Constants (1)
| Name | Value |
|---|---|
DEFAULT_OPTIONS |
array (
'timeout' => 30,
'connect_timeout' => 10,
'verify_ssl' => true,
'follow_redirects' => true,
'max_redirects' => 5,
'user_agent' => 'Mini/1.0 (PSR-18 HTTP Client)',
'headers' =>
array (
),
) |
Properties (1)
private
array $options
Methods (16)
Documentation missing
PSR-18: Send a PSR-7 request and return a PSR-7 response
Configure curl handle from PSR-7 request
Build headers array for curl
Execute curl and return PSR-7 response
Parse curl response into PSR-7 Response
Send a GET request
Send a POST request with form data
Send a POST request with JSON body
Send a PUT request
Send a PUT request with JSON body
Send a PATCH request
Send a PATCH request with JSON body
Send a DELETE request
Send a HEAD request
Send a request with custom method