From 8e36e0c7ca6bf0788ec7cdbb9e34724f2fbdd9f7 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Fri, 13 Sep 2019 11:26:09 +0100 Subject: [PATCH] Live blogging from SymfonyLive London 2019 --- ...-09-13-live-blogging-symfonylive-london.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/source/_posts/2019-09-13-live-blogging-symfonylive-london.md b/source/_posts/2019-09-13-live-blogging-symfonylive-london.md index 7cc2a57e..d782224b 100644 --- a/source/_posts/2019-09-13-live-blogging-symfonylive-london.md +++ b/source/_posts/2019-09-13-live-blogging-symfonylive-london.md @@ -177,3 +177,26 @@ Notifier - Option 2: HTTP request -> Thin app -> return 200 response -> pass to workers * Tip: put Command and CommandHandlers in the same directory + +## HttpClient + +* new symfony component, released in may +* Httpclient contracts, separate package that contains interfaces +* `HttpClient::create()`. `$client->get()` +* JSON decoded with error handling +* Used on symfony.com website (#1391). Replaces Guzzle `Client` for `HttpClientInterface` +* Object is stateless, Guzzle is not. Doesn't handle cookies, cookies are state +* Remove boilerplate - use `toArray()` +* Options as third argument - array of headers, similar to Guzzle + +* What can we do with the Response? + * getStatusCode(): int + * getHeaders(): array + * getContent(): string + * toArray(): array + * cancel(): void + * getInfo(): array - metadata +* Everything is lazy! +* 80% of use-cases covered +* What about PSR-18? + * Decorator/adapter to change to PSR compatible