This package is abandoned and no longer maintained. No replacement package was suggested.

A useful base guzzle client.

Maintainers

Package info

github.com/matthewerskine/guzzle

pkg:composer/matthewerskine/guzzle

Statistics

Installs: 4 129

Dependents: 0

Suggesters: 0

Stars: 1

Open Issues: 0

1.0.0 2017-11-22 14:40 UTC

This package is not auto-updated.

Last update: 2026-03-11 15:27:58 UTC


README

This is a simple base Guzzle Client to quickly consume responses from JSON based services.

Example usage

The respond() will automatically parse out the response from the Guzzle Client so you may quickly interact with it.

<?php

use MatthewErskine\Guzzle\Client;

class FruitService extends Client
{
    public function getFruits()
    {
        // {"data": [{"title": "banana"}, {"title": "apple"}]}
        return $this->respond(
            $this->getHttpClient()->get($this->getUrl().'/bananas')
        );
    }
}

Now in a consuming class we can interact with data directly:

<?php

class FruitRepository
{
    ...

    public function giveMeABanana()
    {
        foreach ($this->fruitService->getFruits() as $fruit) {
            if ($fruit['title'] == 'banana') {
                return $fruit;
            }
        }
    }
}