shpartko-packagist / guzzle-bundle-retry-plugin
Retry Plugin for Guzzle Bundle, a PHP HTTP client library and framework for building RESTful web service clients
1.0.0
2023-08-10 08:10 UTC
Requires
- php: ^7.3 || ^8.0
- caseyamcl/guzzle_retry_middleware: ^2.8
- eightpoints/guzzle-bundle: ^7.6|^8.0
- guzzlehttp/guzzle: ^6.3|^7.0
- symfony/dependency-injection: ^6.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15|^3.20
- php-coveralls/php-coveralls: ^2.1
- phpunit/phpunit: ^8.1|^9.5
This package is auto-updated.
Last update: 2025-01-10 11:08:43 UTC
README
Requirements
- PHP 7.3 or above
- Guzzle Bundle
- Guzzle Retry middleware
Installation
Using composer:
composer.json
{ "require": { "eugenganshorn/guzzle-bundle-retry-plugin": "^1.0" } }
command line
$ composer require eugenganshorn/guzzle-bundle-retry-plugin
Usage
Enable bundle
Symfony 2.x and 3.x
Plugin will be activated/connected through bundle constructor in app/AppKernel.php
, like this:
new EightPoints\Bundle\GuzzleBundle\EightPointsGuzzleBundle([ new EugenGanshorn\Bundle\GuzzleBundleRetryPlugin\GuzzleBundleRetryPlugin(), ])
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:
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(); } } }
Basic configuration
# 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: ~
Advanced configuration
See middleware options: https://github.com/caseyamcl/guzzle_retry_middleware#options
License
This middleware is licensed under the MIT License - see the LICENSE file for details