Talk in English - US at Longhorn PHP Conference 2019
View Slides: https://www.slideshare.net/stevenwadejr/diving-into-guzzle
Checkout the code: https://gist.github.com/stevenwadejr/e3677bcbd0122ff7cb50462a44380a10
Short URL: https://joind.in/talk/41978 (QR-Code (opens in new window))
Often in our applications we need to make HTTP requests to external services either to integrate with an API, upload a file to S3, or perform some other action that requires us to interface over HTTP. PHP doesn’t natively make these requests user friendly so many of us turn to the 3rd-party library Guzzle. But how well do you know Guzzle beyond the basics?
Guzzle is much more than syntactic sugar for HTTP requests. PHP is a synchronous language by nature, but did you know that you can make asynchronous HTTP requests out of the box with Guzzle? It’s functionality extends even further with support for custom request handlers and middleware.
In this talk we’ll start with some basic example requests using Guzzle. Then we’ll look at extending our requests with middleware such as logging, retry middleware, handling failed requests, and mapping responses from 3rd-party APIs. From there, we’ll refactor our synchronous requests to be asynchronous using promises and generators to process our async responses. Finally, we’ll look at how to test our requests without needing to send them over the internet. You’ll leave this presentation with a deeper understanding of the power of Guzzle, how to extend it with your own middleware, how to speed up your application with async requests and how to test your requests without external dependencies.