2017 © Pedro PelĂĄez
 

library guzzlecache

Laravel 5 package for caching Guzzle's GET requests.

image

remic/guzzlecache

Laravel 5 package for caching Guzzle's GET requests.

  • Wednesday, February 3, 2016
  • by RemiCollin
  • Repository
  • 2 Watchers
  • 18 Stars
  • 7,747 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Guzzle Cache Laravel 5 Package

GuzzleCache is a simple wrapper around the GuzzleHttp library, aimed at optimizing API consuming applications by intercepting GET request and storing/retrieving responses from the Laravel's cache engine., (*1)

Installation

Grab the package with composer :, (*2)


composer require remic/guzzlecache:~0.2

Configuration

The GuzzleCache package works both with Laravel 5 and Lumen, but the configuration process is different., (*3)

Laravel

In Laravel, you need to register the packages service provider into your config/app.php configuration file :, (*4)


Remic\GuzzleCache\GuzzleCacheServiceProvider::class,

If you're using facades, add this line to the corresponding section in config/app.php :, (*5)


'GuzzleCache' => Remic\GuzzleCache\Facades\GuzzleCache::class,

GuzzleCache come shipped with a default configuration file, if you wish to override these defaults, you have to publish the configuration file :, (*6)


artisan vendor:publish

Lumen

In Lumen, you need to register the package's service provider into the bootstrap/app.php file :, (*7)


$app->register(Remic\GuzzleCache\GuzzleCacheServiceProvider::class);

If you wish to use the GuzzleCache facade, first make sure $app->withFacades(); is uncommented in bootstrap/app.php, then add the following class alias :, (*8)


class_alias(Remic\GuzzleCache\Facades\GuzzleCache::class, 'GuzzleCache');

In Lumen, the configuration is handled via the .env file at the root of the project. Here are the default values used by GuzzleCache. If you wish to modify these, just copy and paste these to your .env file :, (*9)


GUZZLECACHE_LIFETIME=60 GUZZLECACHE_STORE= GUZZLECACHE_PREFIX=guzzlecache_

Usage

From your L5 application, call:, (*10)


$client = GuzzleCache::client(['base_url' => 'http://httpbin.org']); $res = $client->get('/'); echo $res->getStatusCode();

Here, the $client object is an instance of Guzzle client. You can refer to Guzzle Documentation for more details., (*11)

Specifying a custom lifetime

You can specify an optionnal lifetime when requesting a Guzzle client, that will override the defaults set in GuzzleCache config, for all request made with the object :, (*12)


// Store all the request made with $client for 15 minutes $client = GuzzleCache::client(['base_url' => 'http://httpbin.org'], 15);

License

MIT, (*13)

The Versions

03/02 2016

dev-master

9999999-dev

Laravel 5 package for caching Guzzle's GET requests.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Rémi Collin

api cache lumen http guzzle proxy laravel5

03/02 2016

v0.2

0.2.0.0

Laravel 5 package for caching Guzzle's GET requests.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Rémi Collin

api cache lumen http guzzle proxy laravel5

24/06 2015

v0.1.1

0.1.1.0

Laravel 5 package for caching Guzzle's GET requests.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Rémi Collin

api cache http guzzle proxy l5 laravel5

24/03 2015

v0.1.0

0.1.0.0

Laravel 5 package for caching Guzzle's GET requests.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Rémi Collin

api cache http guzzle proxy l5 laravel5