There are two types of libraries you can use to send HTTP messages; clients and adapters. A client implements the
HttpClient
and/or the HttpAsyncClient
interfaces directly. A client adapter is a class implementing the
interface and forwarding the calls to an HTTP client not implementing the interface. (See Adapter pattern on Wikipedia).
Hint
Modern PHP clients implement the PSR-18 HTTP Client
standard. If you want to do synchronous requests, you don't
need a PHP-HTTP adapter anymore. We keep providing the the curl client and a mock client for testing.
The adapters are still useful if you need the PHP-HTTP HttpAsyncClient
.
Note
All clients and adapters comply with Liskov substitution principle which means that you can easily change one for another without any side effects.
.. toctree:: :hidden: clients/curl-client clients/mock-client clients/symfony-client clients/artax-adapter clients/guzzle7-adapter clients/react-adapter clients/buzz-adapter clients/cakephp-adapter clients/guzzle5-adapter clients/guzzle6-adapter clients/socket-client clients/zend-adapter
Name | Type | Links | Stats |
---|---|---|---|
php-http/curl-client |
Client | :doc:`Docs </clients/curl-client>`, Repo | |
php-http/mock-client |
Client | :doc:`Docs </clients/mock-client>`, Repo | |
symfony/http-client |
Client | :doc:`Docs </clients/symfony-client>`, Repo | |
php-http/artax-adapter |
Adapter | :doc:`Docs </clients/artax-adapter>`, Repo | |
php-http/guzzle7-adapter |
Adapter | :doc:`Docs </clients/guzzle7-adapter>`, Repo | |
php-http/react-adapter |
Adapter | :doc:`Docs </clients/react-adapter>`, Repo |
These are not maintained anymore, but we keep documentation around for now. Please upgrade your applications to use a maintained client or adapter.
Name | Type | Links | Stats |
---|---|---|---|
php-http/socket-client |
Client | :doc:`Docs </clients/socket-client>`, Repo | |
php-http/buzz-adapter |
Adapter | :doc:`Docs </clients/buzz-adapter>`, Repo | |
php-http/cakephp-adapter |
Adapter | :doc:`Docs </clients/cakephp-adapter>`, Repo | |
php-http/guzzle5-adapter |
Adapter | :doc:`Docs </clients/guzzle5-adapter>`, Repo | |
php-http/guzzle6-adapter |
Adapter | :doc:`Docs </clients/guzzle6-adapter>`, Repo | |
php-http/zend-adapter |
Adapter | :doc:`Docs </clients/zend-adapter>`, Repo |
Virtual packages are a way to specify the dependency on an implementation of an interface-only repository without forcing a specific implementation. For HTTPlug, the virtual packages are called php-http/client-implementation (though you should be using psr/http-client-implementation to use PSR-18) and php-http/async-client-implementation.
There is no library registered with those names. However, all client implementations (including client adapters) for
HTTPlug use the provide
section to tell composer that they do provide the client-implementation.