PSR-18
Abstracting HTTP Clients in PHP
PHP Benelux, Antwerp - January 26th, 2019
© David Buchmann
What is the difference between
guzzle/guzzle
and
guzzlehttp/guzzle?
Depending on an implementation

Once upon a time
FOSHttpCache needs to send HTTP requests to varnish for cache invalidation
HTTPlug
=> Márk Sági-Kazár
- HTTP client interfaces
- FOSHttpCache 2.0 depends on HTTPlug instead of Guzzle 6
PHP Framework Interoperability Group (PHP-FIG)
- Initiative from framework and library projects
- Defines PHP Standard Recommendations (PSR)
HTTP Request and Response: PSR-7
- Interface for request
- Extended interface for server side request
- Interface for response
- For server side applications, this is all you need
- When building a client, you need more!
How to create an object without knowing the class?
interface RequestFactoryInterface
{
function createRequest(string $method, $uri)
: RequestInterface;
}
HTTP Message Factories: PSR-17
=> Woody Gilk
- Request factory
- Stream factory
- URI factory
- (Server Request factory, Uploaded File factory, Response factory)
How to send that request?
interface ClientInterface
{
function sendRequest(RequestInterface $request)
: ResponseInterface;
}
What is PSR-18?

HTTP Clien