filipefernandes/laravel-route-retry

A Laravel package to capture and retry failing requests.
1,639 2
Install
composer require filipefernandes/laravel-route-retry
Latest Version:0.0.1
PHP:^8.1
License:MIT
Last Updated:Jan 27, 2026
Links: GitHub  ·  Packagist
Maintainer: filipe9747

Laravel Route Retry

Thumbnail

Laravel Route Retry adds a simple and flexible way to capture failed requests (5xx) and retry them later. It's perfect for handling transient failures in webhooks, external API calls, or any critical route.

Installation

You can install the package via composer:

composer require filipefernandes/laravel-route-retry

You can publish the config file with:

php artisan vendor:publish --tag="retry-config"

Then, run the migrations:

php artisan migrate

Usage

Simple Route Retry

You can enable retries on any route using the retry() macro:

use Illuminate\Support\Facades\Route;

Route::post('/webhooks/stripe', function () {
    // If this fails with 5xx, it will be captured
})->retry(3); // Retry up to 3 times

Adding Tags

Tags help you filter and process retries for specific features:

Route::post('/sync-data', [SyncController::class, 'handle'])
    ->retry(5)
    ->tags(['erp', 'priority-high']);

Processing Retries

To process pending retries, add the following command to your app/Console/Kernel.php:

$schedule->command('retry:process')->everyMinute();

You can also filter retries by tag or ID:

php artisan retry:process --tag=erp
php artisan retry:process --id=1 --id=2 --id=3
php artisan retry:process --fingerprint=a8...

Disabling Middleware

If you need to retry requests without running the original route middleware (e.g., if authentication tokens have expired), use the --without-middleware option:

php artisan retry:process --without-middleware

Configuration

The published configuration file config/retry.php allows you to customize:

  • table_name: The table where retries are stored.
  • storage_disk: The disk used for temporary file storage (defaults to local).
  • max_retries: Global default for maximum retry attempts.
  • delay: The initial delay before the first retry attempt.

Events

The package dispatches events throughout the retry lifecycle:

  • LaravelRouteRetry\Events\RequestCaptured: Dispatched when a failure is first captured.
  • LaravelRouteRetry\Events\RetrySucceeded: Dispatched when a retry attempt results in a 2xx response.
  • LaravelRouteRetry\Events\RetryFailed: Dispatched when a retry fails or reaches the maximum limit.

License

The MIT License (MIT). Please see License File for more information.

Related Packages

gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

631,580,251 9,707
laravel/framework

The Laravel Framework.

580,311,802 34,925
laravel/tinker

Powerful REPL for the Laravel framework.

489,754,436 7,444