Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eugenganshorn/guzzlebundleretryplugin
Retry Plugin for EightPointsGuzzleBundle
https://github.com/eugenganshorn/guzzlebundleretryplugin
bundle curl guzzle guzzle-bundle-plugin guzzle-middleware http http-client middleware plugin retry symfony symfony-bundle
Last synced: 24 days ago
JSON representation
Retry Plugin for EightPointsGuzzleBundle
- Host: GitHub
- URL: https://github.com/eugenganshorn/guzzlebundleretryplugin
- Owner: EugenGanshorn
- License: mit
- Created: 2019-06-04T17:49:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-10-20T13:39:33.000Z (about 1 year ago)
- Last Synced: 2024-04-23T06:25:40.359Z (7 months ago)
- Topics: bundle, curl, guzzle, guzzle-bundle-plugin, guzzle-middleware, http, http-client, middleware, plugin, retry, symfony, symfony-bundle
- Language: PHP
- Homepage:
- Size: 47.9 KB
- Stars: 5
- Watchers: 1
- Forks: 13
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GuzzleBundleRetryPlugin
[![Build Status](https://travis-ci.org/EugenGanshorn/GuzzleBundleRetryPlugin.svg?branch=master)](https://travis-ci.org/EugenGanshorn/GuzzleBundleRetryPlugin)
[![Coverage Status](https://coveralls.io/repos/github/EugenGanshorn/GuzzleBundleRetryPlugin/badge.svg?branch=master)](https://coveralls.io/github/EugenGanshorn/GuzzleBundleRetryPlugin?branch=master)## Requirements
- PHP 8.0 or above
- [Guzzle Bundle][1]
- [Guzzle Retry middleware][2]## Installation
Using [composer][3]:##### composer.json
``` json
{
"require": {
"eugenganshorn/guzzle-bundle-retry-plugin": "^1.0"
}
}
```##### command line
``` bash
$ composer require eugenganshorn/guzzle-bundle-retry-plugin
```
## Usage
### Enable bundle#### Symfony 4
Plugin will be activated/connected through bundle constructor in `app/AppKernel.php`, like this:
Find next lines:```php
foreach ($contents as $class => $envs) {
if (isset($envs['all']) || isset($envs[$this->environment])) {
yield new $class();
}
}
```and replace them by:
```php
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();
}
}
}
```
#### Symfony 5 & 6
Override the `registerBundles` method in `src/Kernel.php` to connect the plugin to the bundle:```php
public function registerBundles(): iterable
{
$contents = require $this->getBundlesPath();
foreach ($contents as $class => $envs) {
if ($envs[$this->environment] ?? $envs['all'] ?? false) {
if ($class === EightPointsGuzzleBundle::class) {
yield new $class([
new GuzzleBundleRetryPlugin(),
]);
} else {
yield new $class();
}
}
}
}
```### Basic configuration
``` yaml
# app/config/config.yml // config/packages/eight_points_guzzle.yamleight_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[1]: https://github.com/8p/EightPointsGuzzleBundle
[2]: https://github.com/caseyamcl/guzzle_retry_middleware
[3]: https://getcomposer.org/