Building HTTP clients with Guzzle

Titas Gailius
Sep 4, 2018 · 1 min read

Whenever you’re integrating some external service that exposes an HTTP API, you’ll end up building a client to interact with that service.

There’re many different ways to build these http clients although the 3 most common approaches I encountered are listed below.

Which one do you prefer? Do you have any alternatives? Discuss.

1. Creating a client class that extends guzzle.


2. Creating a client class that handles all the logic and calls guzzle.


3. Creating a client class where all the logic is handled by guzzle middleware.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade