2017 © Pedro Peláez
 

library guzzle-bundle-cache-plugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

image

gregurco/guzzle-bundle-cache-plugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

  • Wednesday, May 9, 2018
  • by gregurco
  • Repository
  • 2 Watchers
  • 4 Stars
  • 3,952 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 70 % Grown

The README.md

Guzzle Bundle Cache Plugin

Build Status Coverage Status SensioLabsInsight, (*1)

This plugin integrates cache functionality into Guzzle Bundle, a bundle for building RESTful web service clients., (*2)

Requirements

Installation

Using [composer][3]:, (*3)

composer.json

``` json { "require": { "gregurco/guzzle-bundle-cache-plugin": "dev-master" } }, (*4)


##### command line ``` bash $ composer require gregurco/guzzle-bundle-cache-plugin

Usage

Enable bundle

Symfony 2.x and 3.x

Plugin will be activated/connected through bundle constructor in app/AppKernel.php, like this:, (*5)

``` php new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([ new Gregurco\Bundle\GuzzleBundleCachePlugin\GuzzleBundleCachePlugin(), ]), (*6)


#### Symfony 4 The registration of bundles was changed in Symfony 4 and now you have to change `src/Kernel.php` to achieve the same functionality. Find next lines: ```php foreach ($contents as $class => $envs) { if (isset($envs['all']) || isset($envs[$this->environment])) { yield new $class(); } }

and replace them by:, (*7)

foreach ($contents as $class => $envs) {
    if (isset($envs['all']) || isset($envs[$this->environment])) {
        if ($class === \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle::class) {
            yield new $class([
                new \Gregurco\Bundle\GuzzleBundleCachePlugin\GuzzleBundleCachePlugin(),
            ]);
        } else {
            yield new $class();
        }
    }
}

Basic configuration

``` yaml, (*8)

app/config/config.yml

eight_points_guzzle: clients: api_payment: base_url: "http://api.domain.tld", (*9)

        # define headers, options

        # plugin settings
        plugin:
            cache:
                enabled: true

### Configuration with specific cache strategy ``` yaml # app/config/services.yml services: acme.filesystem_cache: class: Doctrine\Common\Cache\FilesystemCache arguments: ['/tmp/'] public: false acme.doctrine_cache_storage: class: Kevinrob\GuzzleCache\Storage\DoctrineCacheStorage arguments: ['@acme.filesystem_cache'] public: false acme.private_cache_strategy: class: Kevinrob\GuzzleCache\Strategy\PrivateCacheStrategy arguments: ['@acme.doctrine_cache_storage'] public: false

``` yaml, (*10)

app/config/config.yml

eight_points_guzzle: clients: api_payment: plugin: cache: enabled: true strategy: "acme.private_cache_strategy", (*11)


More information about cache strategies can be found here: [Kevinrob/guzzle-cache-middleware][2] ### Invalidate cache ```php # get client $apiPaymentClient = $this->get('eight_points_guzzle.client.api_payment'); # do a request $apiPaymentClient->request('GET', 'ping'); # invalidate cache $event = new InvalidateRequestEvent($apiPaymentClient, 'GET', 'ping'); $this->get('event_dispatcher')->dispatch(GuzzleBundleCacheEvents::INVALIDATE, $event);

License

This middleware is licensed under the MIT License - see the LICENSE file for details, (*12)

The Versions

09/05 2018

dev-master

9999999-dev https://github.com/gregurco/GuzzleBundleCachePlugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework cache rest http client web service http client

09/05 2018

dev-doc_sf4

dev-doc_sf4 https://github.com/gregurco/GuzzleBundleCachePlugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework cache rest http client web service http client

16/11 2017

v1.0.4

1.0.4.0 https://github.com/gregurco/GuzzleBundleCachePlugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework cache rest http client web service http client

16/11 2017

v1.0.3

1.0.3.0 https://github.com/gregurco/GuzzleBundleCachePlugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework cache rest http client web service http client

13/11 2017

v1.0.2

1.0.2.0 https://github.com/gregurco/GuzzleBundleCachePlugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework cache rest http client web service http client

03/11 2017

v1.0.1

1.0.1.0 https://github.com/gregurco/GuzzleBundleCachePlugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework cache rest http client web service http client

26/10 2017

v1.0.0

1.0.0.0 https://github.com/gregurco/GuzzleBundleCachePlugin

Cache Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients

  Sources   Download

MIT

The Requires

 

The Development Requires

plugin middleware curl framework cache rest http client web service http client