talira

HTTP client abstraction and plugins for PHP

open sourceMITfree

HTTPlug, from the PHP-HTTP project, is an HTTP client abstraction for PHP built on PSR-7 messages. It defines an asynchronous HTTP client interface, plus a synchronous one with the same signature as PSR-18, so a library can depend on the interface instead of a concrete client. Around it, PHP-HTTP ships clients (socket, cURL), adapters for other clients such as Guzzle, an implementation-independent plugin system for authentication, cookies and more, and php-http/discovery, which finds and installs well-known PSR-17, PSR-18 and HTTPlug implementations.

Problems it solves

  • let my PHP SDK work with whatever HTTP client the user already has
  • find an installed PSR-18 HTTP client automatically in a PHP library
  • send asynchronous HTTP requests in PHP without tying to one client

Features

  • asynchronous HTTP client interface with promises
  • synchronous client interface matching PSR-18
  • discovery and auto-installation of PSR-17, PSR-18 and HTTPlug implementations
  • client-independent plugins for authentication, cookies and more
  • clients for sockets and cURL, and adapters for Guzzle and others

Limitations

  • For synchronous requests its makers recommend using PSR-18 directly rather than HTTPlug.1

Alternatives

The same job

These do what HTTPlug does.

  1. Guzzle PHP HTTP client
  2. Buzz (PHP HTTP client) PHP's lightweight HTTP client
  3. PHP Curl Class Object-oriented wrapper around PHP's cURL extension for HTTP requests

Compare HTTPlug with the top 3