This package is abandoned and no longer maintained. The author suggests using the guzzlehttp/guzzle package instead.

PHP PSR-7 compatible HTTP client (using cURL)

2.7.0 2021-01-29 18:58 UTC

This package is auto-updated.

Last update: 2021-11-16 18:38:33 UTC


PHP PSR-7 compatible HTTP client (using cURL)

Latest Stable Version License



Install directly via Composer:

$ composer require phyrexia/http

Basic Usage

require 'vendor/autoload.php';

use Phyrexia\Http\Client as HttpClient;

$response = HttpClient::get('');

//And now with a query string
$response = HttpClient::get('', 'a=1&b=c');

//Query string in array format
$response = HttpClient::get('', array('a' => 1, 'b' => 'c'));

//An HTTP POST with some data
$response = HttpClient::post('', array('user' => 'test', 'submit' => 1));

//You can also build an HttpClient object, and provide cURL options (::get, ::post and ::head support cURL options too)
$client = new HttpClient('', 'GET', array(CURLOPT_CONNECTTIMEOUT => 2, CURLOPT_TIMEOUT => 5));
$response = $client->send();

//The response is a Response object, if you just want the body, you can cast it as a string
$body = (string)HttpClient::get('');