Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Modular, Object oriented CURL wrapper
PHP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
PHP
LICENSE
README.md

README.md

php-http-request

Modular, Object oriented CURL wrapper

Usage

$response = $http->url('http://localhost')
    ->body(array('a' => 'aa'))
    ->setContentType('application/json')
    ->POST();
$body = $response->json();

You can use the following http methods:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
  • OPTIONS
  • HEAD

This package provides the multicurl process

// create 3 requests
$multiOpener = $http->createCurlGroup();

$multiOpener->url('http://localhost')
    ->GET();
$multiOpener->url('http://localhost')
    ->body(array('pippo' => 1))
    ->POST();
$multiOpener->url('http://localhost')
    ->body(array('pippo' => 1))
    ->setContentType('application/json')
    ->PUT();

// execute the requests return an array with all responses
$responses = $http->execute($multiOpener);

foreach ($responses as $response) {
    var_dump($response->json());
}

Or you can use the shortcut:

$response = HTTP::get('http://localhost', array('key' => 1));
var_dump($response->body());
Something went wrong with that request. Please try again.