Details
- Tag
- 20170901
![Build Status](http://travis-ci.org/nategood/httpful)
Httpful is a simple Http Client library for PHP 5.3+. There is an emphasis of readability, simplicity, and flexibility – basically provide the features and flexibility to get the job done and make those features really easy to use.
Features
Here's something to whet your appetite. Search the twitter API for tweets containing "#PHP". Include a trivial header for the heck of it. Notice that the library automatically interprets the response as JSON (can override this if desired) and parses it as an array of objects.
$url = "http://search.twitter.com/search.json?q=" . urlencode('#PHP'); $response = Request::get($url) ->withXTrivialHeader('Just as a demo') ->send(); foreach ($response->body->results as $tweet) { echo "@{$tweet->from_user} tweets \"{$tweet->text}\"\n"; }
A PHP Archive (or .phar) file is available for downloading. Simply download the .phar, drop it into your project, and include it like you would any other php file. _This method is ideal smaller projects, one off scripts, and quick API hacking_.
<?php include('httpful.phar'); $r = \Httpful\Request::get($uri)->sendIt(); ...
Httpful is PSR-0 compliant and can be installed using composer. Simply add nategood/httpful to your composer.json file. _Composer is the sane alternative to PEAR. It is excellent for managing dependancies in larger projects_.
{ "require": { "nategood/httpful": "*" } }
Because Httpful is PSR-0 compliant, you can also just clone the Httpful repository and use a PSR-0 compatible autoloader to load the library, like Symfony's. Alternatively you can use the PSR-0 compliant autoloader included with the Httpful (simply require("bootstrap.php")).
You can checkout the Httpful Landing Page for more info including many examples and documentation.
Httpful highly encourages sending in pull requests. When submitting a pull request please: