- PHP 7.3 or above
- Guzzle Bundle
- Guzzle Retry middleware
Using composer:
{
"require": {
"eugenganshorn/guzzle-bundle-retry-plugin": "^1.0"
}
}
$ composer require eugenganshorn/guzzle-bundle-retry-plugin
Plugin will be activated/connected through bundle constructor in app/AppKernel.php
, like this:
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([
new EugenGanshorn\Bundle\GuzzleBundleRetryPlugin\GuzzleBundleRetryPlugin(),
])
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:
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
and replace them by:
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
if ($class === \EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle::class) {
yield new $class([
new \EugenGanshorn\Bundle\GuzzleBundleRetryPlugin\GuzzleBundleRetryPlugin(),
]);
} else {
yield new $class();
}
}
}
# app/config/config.yml // config/packages/eight_points_guzzle.yaml
eight_points_guzzle:
clients:
your_client:
base_url: "http://api.domain.tld"
# plugin settings
plugin:
retry:
~
See middleware options: https://github.com/caseyamcl/guzzle_retry_middleware#options
This middleware is licensed under the MIT License - see the LICENSE file for details