PHP-HTTP: standardized HTTP for PHP¶
PHP-HTTP is the next step in standardizing HTTP interaction for PHP packages.
It builds on top of PSR-7, which defines interfaces for HTTP requests and responses. The HTTPlug HTTP client interface has been standardized in PSR-18_ to define synchronous HTTP requests. When using a client that implements PSR-18, we recommend directly using PSR-18 and not HTTPlug nor our adapters.
However, PSR-18 does not define asynchronous requests. HTTPlug provides interfaces for those, but to do that also needs to define how promises are implemented.
PHP-HTTP has three goals:
- Encourage package developers to depend on the simple HTTPlug interface instead of concrete HTTP clients.
- Provide good quality HTTP-related packages to the PHP community.
- Now that PSR-18 exists, we miss a PSR for asynchronous requests. This is blocked by not having a PSR for promises.
HTTPlug abstracts from HTTP clients written in PHP, offering a simple interface. It also provides an implementation-independent plugin system to build pipelines regardless of the HTTP client implementation used.
Read more about HTTPlug.
They use us¶
PHP-HTTP offers several packages:
|Clients||HTTP clients: Socket, cURL and others||
|Client adapters||Adapters for other clients: Guzzle, React and others||
|Plugins||Implementation-independent authentication, cookies and more||
HTTPlug, as a working example of an HTTP client interface, can serve as a basis for discussion around a future HTTP client PSR.