Home

Awesome

Httpful

Httpful is a simple Http Client library for PHP 8.0+. 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

Sneak Peak

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.


// Make a request to the GitHub API with a custom
// header of "X-Trvial-Header: Just as a demo".
$url = "https://api.github.com/users/nategood";
$response = \Httpful\Request::get($url)
    ->expectsJson()
    ->withXTrivialHeader('Just as a demo')
    ->send();

echo "{$response->body->name} joined GitHub on " .
                        date('M jS', strtotime($response->body->created_at)) ."\n";

Installation

Composer

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 dependencies in larger projects.

{
    "require": {
        "nategood/httpful": "*"
    }
}

Install from Source

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")).

Build your Phar

If you want the build your own Phar Archive you can use the build script included. Make sure that your php.ini has the Off or 0 value for the phar.readonly setting. Also you need to create an empty downloads directory in the project root.

Contributing

Httpful highly encourages sending in pull requests. When submitting a pull request please:

Changelog

1.0.0

0.3.2

0.3.1

0.3.0

0.2.20

0.2.19

0.2.18

0.2.17

0.2.16

0.2.15

0.2.14

0.2.13

0.2.12

0.2.11

0.2.10

0.2.9

0.2.8

0.2.7

0.2.6

0.2.5

0.2.4

0.2.3

0.2.2

0.2.1

0.2.0

0.1.6

0.1.5

0.1.4

0.1.3

0.1.2

0.1.1

0.1.0