HTTP Client library, RESTful HTTP Requests have never been easier.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Http
tests
.gitignore
CHANGELOG.md
LICENSE.md
README.md
autoload.php
composer.json
phpunit.xml.dist

README.md

#HttpRequest - HTTP Requests the easy way# By Allan Rehhoff

<?php
	// Assuming you have an autoloader in place.
	$request = new Http\Request("http://httpbin.org/post");
	$response = $request->post(["foo" => "bar", "john" => "doe"]);

	print_r($response->asObject()); // Assumes a valid JSON response

	// Alternatively you can include the bundled autoloader
	require "autoload.php";
?>

You can tell cURL to fail upon error using Http\Request::failOnError($bool);

<?php
	// Alternatively you can include the bundled autoloader
	require "autoload.php";

	try {
		$req = new Http\Request("https://httpbin.org/status/418");
		$response = $req->failOnError(true)->get();
	} catch(Exception $e) {
		// $response will be NULL
		print $e->getCode();
		print $e->getMessage();
	}
?>

The library wraps around PHP's built in curl library, eliminating all the hassle and the need for $ch variables. (god I hate $ch)
Please inspect the library source and test cases for further documentation and usage examples.

This tool is licensed under WTFPL