cline / retry
Comprehensive retry strategies with exponential backoff, jitter, and circuit breaker support for PHP 8.4+
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/cline/retry
Requires
- php: ^8.4.0
- spatie/laravel-package-tools: ^1.92
Requires (Dev)
- cline/php-cs-fixer: ^1.0.4
- driftingly/rector-laravel: ^2.0.7
- ergebnis/composer-normalize: ^2.49@dev
- laravel/pint: ^1.25.1
- orchestra/testbench: ^10.6
- pestphp/pest: ^3.8.4
- pestphp/pest-plugin-laravel: ^3.2
- pestphp/pest-plugin-type-coverage: ^3.6.1
- phpstan/phpstan: ^2.1.30
- rector/rector: ^2.2.1
- symfony/var-dumper: ^7.3.4
README
A comprehensive retry library for PHP 8.4+ featuring multiple backoff strategies, jitter support, and a fluent interface for building resilient applications. Designed for handling transient failures in network requests, database operations, and external service calls.
Requirements
Requires PHP 8.4+
Installation
composer require cline/retry
Quick Start
use Cline\Retry\Retry; use Cline\Retry\Strategy\ExponentialBackoff; use function Cline\Retry\retry; // Functional style with exponential backoff $result = retry(5, ExponentialBackoff::milliseconds(100))( fn() => $apiClient->fetchData() ); // OOP style with fluent interface $result = Retry::times(5) ->withBackoff(ExponentialBackoff::seconds(1)) ->withMaxDelay(30_000_000) // 30 seconds ->execute(fn() => $database->query());
Documentation
- Backoff Strategies - All available backoff algorithms and when to use them
- Retry Patterns - Common retry patterns for APIs, databases, and more
- Functional API - Using the
retry()function with closures - OOP API - Fluent interface with conditional retries and max delays
- Examples - Real-world usage examples and patterns
Features
- 8 Backoff Strategies: Constant, Linear, Exponential, Exponential+Jitter, Fibonacci, Decorrelated Jitter, Polynomial, and Max Delay Decorator
- Functional & OOP APIs: Choose the style that fits your codebase
- Conditional Retries: Retry only on specific exceptions or conditions
- Max Delay Caps: Prevent exponential backoff from growing too large
- Immutable: All configuration methods return new instances
- Type Safe: Full PHP 8.4 type coverage with readonly properties
- Well Tested: 244 tests with 2,539 assertions covering all edge cases
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.
Credits
License
The MIT License. Please see License File for more information.