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

Requester class to wrap guzzle and retry subscriber

1.1.0 2015-02-26 22:17 UTC

This package is auto-updated.

Last update: 2019-09-06 07:06:21 UTC


Simple Requester class to wrap guzzle and the retry subscriber

Build Status Scrutinizer Code Quality Coverage Status License Latest Version Total Downloads

This package requires PHP >=5.4


Install via composer - edit your composer.json to require the package.

"require": {
    "pulkitjalan/requester": "2.*"

Then run composer update in your terminal to pull it in.

Laravel 5

There is a Laravel 5 service provider and facade available.

Add the following to the providers array in your config/app.php


Next add the following to the aliases array in your config/app.php

'Requester' => 'PulkitJalan\Requester\Facades\Requester'

Next run php artisan vendor:publish --provider="pulkitjalan\requester\RequesterServiceProvider" --tag="config" to publish the config file.

Looking for a Laravel 4 compatible version?

Checkout the 1.0 branch


The requester class has a dependency of guzzle and takes in an instance of guzzle as the first param.

This package also uses a few guzzle subscribers. https://github.com/guzzle/retry-subscriber for retry functionality and https://github.com/guzzle/log-subscriber for logging.

Available request methods: get, head, delete, put, patch, post, options


use PulkitJalan\Requester\Requester;
use GuzzleHttp\Client as GuzzleClient;

$requester = new Requester(new GuzzleClient());

// simple get request

Altering the default retry behaviour. See retry-subscriber for more info.

// retry 10 times, with a 1 second wait on a 503 error

// disabling retry

Disabling ssl check

// ssl check disabled

Use http instead of https

// disable https and use http

// use http

Create a Post request

// Create a post request
    'body' => [
        'title' => 'some title'

// Upload a file
    'body' => [
        'title' => 'Some image',
        'description' => 'Some image description'

Guzzle 5 uses RingPHP and has the added functionality of performing request asynchronously.

Performing asynchronous requests

// Create a post request
$response = $requester->url('example.com')->async(true)->get();

// Use the response asynchronously
$this->response = $response->then(function ($response) {
    return $response->getBody();

// Use the response synchronously
$this->response = $response->getBody();

Logging guzzle requests to file. See log-subscriber for more info.

use PulkitJalan\Requester\Requester;
use GuzzleHttp\Client as GuzzleClient;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('/path/to/your.log', Logger::INFO));

$requester = new Requester(new GuzzleClient());

// request and response logged to file

// Use the second param to update the format
$requester = new Requester(new GuzzleClient());
$requester->addLogger($log, 'DEBUG');