PHP code example of gregurco / guzzle-bundle-cache-plugin

1. Go to this page and download the library: Download gregurco/guzzle-bundle-cache-plugin library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gregurco / guzzle-bundle-cache-plugin example snippets


foreach ($contents as $class => $envs) {
    if (isset($envs['all']) || isset($envs[$this->environment])) {
        yield new $class();
    }
}

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();
        }
    }
}

# 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);
 php 
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([
    new Gregurco\Bundle\GuzzleBundleCachePlugin\GuzzleBundleCachePlugin(),
])