Copied from: https://github.com/IMSGlobal/caliper-php/issues/126#issuecomment-226624750
I've recently learned that Guzzle is a popular HTTP client library for PHP: http://guzzlephp.org/
This package has a lot of nice features, including:
- Simple interface for building query strings, POST requests, streaming large uploads, streaming large downloads, using HTTP cookies, uploading JSON data, etc...
- Can send both synchronous and asynchronous requests using the same interface.
- Uses PSR-7 interfaces for requests, responses, and streams. This allows you to utilize other PSR-7 compatible libraries with Guzzle.
- Abstracts away the underlying HTTP transport, allowing you to write environment and transport agnostic code; i.e., no hard dependency on cURL, PHP streams, sockets, or non-blocking event loops.
- Middleware system allows you to augment and compose client behavior.
I've emphasized the most attractive features. caliper-php's HttpRequestor class already abstracts cURL vs. pecl_http. While I think we still should offer Requestor classes that let the developer specifically select one of those libraries over the other, we should also replace the current abstraction with Guzzle. It's gotten a lot more field testing and may be more reliable.
The code is available in GitHub: https://github.com/guzzle/guzzle
It can be included in caliper-php by adding it to the composer.json file: https://packagist.org/packages/guzzlehttp/guzzle