Skip to content


Repository files navigation

Full Documentation at

Supercharge your app or SDK with a testing library specifically for Guzzle. Guzzler covers the process of setting up a mock handler, recording history of requests, and provides several convenience methods for creating expectations and assertions on that history.


composer require --dev --prefer-dist blastcloud/guzzler

Example Usage


use BlastCloud\Guzzler\UsesGuzzler;
use GuzzleHttp\Client;

class SomeTest extends TestCase
    use UsesGuzzler;

    public $classToTest;

    public function setUp(): void
        $client = $this->guzzler->getClient([
            /* Any configs for a client */
            "base_uri" => ""
        // You can then inject this client object into your code or IOC container.
        $this->classToTest = new ClassToTest($client);

    public function testSomethingWithExpectations()
            ->withHeader("X-Authorization", "some-key")
            ->willRespond(new Response(201));

    public function testSomethingWithAssertions()
            new Response(204),
            new \Exception("Some message"),
            // any needed responses to return from the client.
        // ... Some other number of calls
        $this->guzzler->assertAll(function ($expect) {
            return $expect->withHeader("Authorization", "some-key");


Full Documentation


Guzzler is open-source software licensed under the MIT License.