A few tools for working with Guzzle

0.4.0 2022-09-07 15:21 UTC

This package is auto-updated.

Last update: 2023-03-07 16:23:09 UTC


A PHP library offering some add-ons for Guzzle.

release build coverage


The recommended method of installing this library is via Composer.

Run the following command from your project root:

$ composer require duncan3dc/guzzle-tools

Quick Examples


When working with Guzzle I got bored of searching for the solution to output the request/response every time I wanted a quick debug, this library makes it easy:

$client = \duncan3dc\Guzzle\Factory::getClient();

$client->request("GET", "http://example.com/");

Running the above would output this on the command line:

GET / HTTP/1.1
User-Agent: GuzzleHttp/6.2.1 curl/7.47.0 PHP/7.1.0RC3
Host: example.com
HTTP/1.1 200 OK
Cache-Control: max-age=604800
Content-Type: text/html
Date: Mon, 09 Jan 2017 14:42:17 GMT
Etag: "359670651+gzip+ident"
Expires: Mon, 16 Jan 2017 14:42:17 GMT
Last-Modified: Fri, 09 Aug 2013 23:54:35 GMT
Server: ECS (ewr/15BD)
Vary: Accept-Encoding
X-Cache: HIT
x-ec-custom-error: 1
Content-Length: 1270

<!doctype html>
    <title>Example Domain</title>
    <h1>Example Domain</h1>
    <p>This domain is established to be used for illustrative examples in documents. You may use this
    domain in examples without prior coordination or asking for permission.</p>
    <p><a href="http://www.iana.org/domains/example">More information...</a></p>

Request Building

As of version 6.0.0 Guzzle no longer offers a way to build a request instance to send later, this library provides a simple workaround:

$request = \duncan3dc\Guzzle\Request::make("GET", "https://example.com/", [
    "query" =>  [
        "date"  =>  date("Y-m-d"),

# There's also an alias on the main factory class
$request = \duncan3dc\Guzzle\Factory::request("GET", "https://example.com/");

Simple Requests

When all you need is a basic GET/POST, you can use the Http class:

$response = \duncan3dc\Guzzle\Http::get("https://example.com/", [
    "date"  =>  date("Y-m-d"),

$response = \duncan3dc\Guzzle\Http::post("https://example.com/", [
    "date"  =>  date("Y-m-d"),


A Changelog has been available since the beginning of time

Where to get help

Found a bug? Got a question? Just not sure how something works?
Please create an issue and I'll do my best to help out.
Alternatively you can catch me on Twitter

duncan3dc/guzzle-tools for enterprise

Available as part of the Tidelift Subscription

The maintainers of duncan3dc/guzzle-tools and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.