athlon1600/php-curl-client
Lightweight, extensible PHP cURL client (PHP 7.3–8.4). Make GET/POST or fully customized requests and always receive a standardized Response with status, body, error, and typed cURL info for IDE autocomplete.
Very simple curl client. Easy to use and extend to make it into your own custom HTTP client.
:heavy_check_mark: Supports PHP from version 7.3 to 8.4
composer require athlon1600/php-curl-client "^1.0"
use Curl\Client;
$client = new Client();
// returns standardized Response object no matter what
$response = $client->get('https://stackoverflow.com');
// 200
$status = $response->status;
// HTML content
$body = $response->body;
// curl_error() OR null
$error = $response->error;
// CurlInfo instance
$info = $response->info;
Update: $response->info now returns an object that will have an auto-complete on your IDE.
;
Works with POST requests too:
$client->post('http://httpbin.org/post', ['username' => 'bob', 'password' => 'test']);
or you can issue a completely customized request:
$client->request('GET', 'https://www.whatismyip.com/', null, [
'User-Agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X)'
], [
CURLOPT_PROXY => '127.0.0.1:8080',
CURLOPT_TIMEOUT => 10
]);
How can I help you explore Laravel packages today?