PHPackages                             wendelladriel/laravel-idempotency - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. wendelladriel/laravel-idempotency

ActiveLibrary[HTTP &amp; Networking](/categories/http)

wendelladriel/laravel-idempotency
=================================

HTTP Idempotency Middleware for Laravel applications

v1.1.0(3mo ago)1404.4k↑14.9%5MITPHPPHP ^8.3CI passing

Since Apr 22Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/WendellAdriel/laravel-idempotency)[ Packagist](https://packagist.org/packages/wendelladriel/laravel-idempotency)[ Fund](https://www.paypal.me/wendelladriel)[ GitHub Sponsors](https://github.com/WendellAdriel)[ RSS](/packages/wendelladriel-laravel-idempotency/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (4)Dependencies (8)Versions (6)Used By (0)

 [![Laravel Idempotency](https://github.com/wendelladriel/laravel-idempotency/raw/main/art/banner.png)](https://github.com/wendelladriel/laravel-idempotency/raw/main/art/banner.png)Laravel Idempotency
===================

[](#laravel-idempotency)

 HTTP idempotency middleware for Laravel applications

 [![Packagist](https://camo.githubusercontent.com/2afcb3e92526433cd077374f1b011374836744f8873bf707f1285ffa1c3cb439/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f77656e64656c6c61647269656c2f6c61726176656c2d6964656d706f74656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wendelladriel/laravel-idempotency) [![PHP from Packagist](https://camo.githubusercontent.com/c91121f84c8fad59dfaad58bbf7d507b5c9efdc86d66d7a8c3a596f2a2bf9854/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f77656e64656c6c61647269656c2f6c61726176656c2d6964656d706f74656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wendelladriel/laravel-idempotency) [![Laravel versions](https://camo.githubusercontent.com/0bd74a3b2b77698973207d3d69b231292567252eeb93b5d172ab173bfc1b41a3/68747470733a2f2f62616467652e6c61726176656c2e636c6f75642f62616467652f77656e64656c6c61647269656c2f6c61726176656c2d6964656d706f74656e63793f7374796c653d666c6174)](https://packagist.org/packages/wendelladriel/laravel-idempotency) [![GitHub Workflow Status (main)](https://camo.githubusercontent.com/f12cee646f19b31b9c2b9f57cd6ca53bcf9d43d1c1f7e73b9558a32528bcd26a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f77656e64656c6c61647269656c2f6c61726176656c2d6964656d706f74656e63792f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d5465737473267374796c653d666c61742d737175617265)](https://github.com/wendelladriel/laravel-idempotency/actions) [![Total Downloads](https://camo.githubusercontent.com/6c725e697136b3f606025418a4f05b291b276a5d2a4598a82a2131965582517b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f77656e64656c6c61647269656c2f6c61726176656c2d6964656d706f74656e63792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/wendelladriel/laravel-idempotency)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require wendelladriel/laravel-idempotency
```

You can publish the config file with:

```
php artisan vendor:publish --tag="idempotency"
```

Usage
-----

[](#usage)

Attach the middleware to routes that create or update data:

```
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use WendellAdriel\Idempotency\Http\Middleware\Idempotent;

Route::post('/orders', function (Request $request) {
    return response()->json([
        'id' => 1,
        'item' => $request->input('item'),
    ], 201);
})->middleware(Idempotent::class);
```

By default, the middleware expects an `Idempotency-Key` header. When the same key is sent again with the same request data, the package replays the original response instead of executing your route again.

Customize a single route with `Idempotent::using`:

```
use WendellAdriel\Idempotency\Enums\IdempotencyScope;
use WendellAdriel\Idempotency\Http\Middleware\Idempotent;

Route::post('/payments', ChargePaymentController::class)->middleware(
    Idempotent::using(
        ttl: 600,
        required: false,
        scope: IdempotencyScope::Ip,
        header: 'X-Idempotency-Key',
        lockTimeout: 30,
    )
);
```

You may also use the `idempotent` middleware alias:

```
Route::post('/orders', StoreOrderController::class)->middleware('idempotent');
```

If you prefer attributes, use the package's `#[Idempotent]` attribute on a controller class or method:

```
use Symfony\Component\HttpFoundation\Response;
use WendellAdriel\Idempotency\Attributes\Idempotent;

#[Idempotent]
class OrderController
{
    public function store(): Response
    {
        // ...
    }
}
```

Generate a key in application code when needed:

```
use WendellAdriel\Idempotency\Idempotency;

$key = Idempotency::key();
```

Inspect and prune cached entries with the included Artisan commands:

```
php artisan idempotency:list
php artisan idempotency:forget --key=checkout-1 --force
```

Access the full documentation [here](https://laravel-idempotency.wendelladriel.com).

Changelog
---------

[](#changelog)

Please see [CHANGELOG](https://laravel-idempotency.wendelladriel.com/getting-started/changelog) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Thank you for considering contributing to Laravel Idempotency! You can read the contribution guide [here](CONTRIBUTING.md).

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Wendell Adriel](https://github.com/WendellAdriel)
- [All Contributors](../../contributors)

License
-------

[](#license)

Laravel Idempotency is open-sourced software licensed under the [MIT license](LICENSE).

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

92d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/565cea386dcfc4df5188a338113624866e65e4b31b209a7a99bb6c4c272e8731?d=identicon)[wendell\_adriel](/maintainers/wendell_adriel)

---

Top Contributors

[![WendellAdriel](https://avatars.githubusercontent.com/u/11641518?v=4)](https://github.com/WendellAdriel "WendellAdriel (21 commits)")[![HPWebdeveloper](https://avatars.githubusercontent.com/u/16323354?v=4)](https://github.com/HPWebdeveloper "HPWebdeveloper (1 commits)")[![raphaelstolt](https://avatars.githubusercontent.com/u/48225?v=4)](https://github.com/raphaelstolt "raphaelstolt (1 commits)")

---

Tags

apihttphttp-requestsidempotencylaravellaravel-packagehttpapilaravelidempotency

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/wendelladriel-laravel-idempotency/health.svg)

```
[![Health](https://phpackages.com/badges/wendelladriel-laravel-idempotency/health.svg)](https://phpackages.com/packages/wendelladriel-laravel-idempotency)
```

###  Alternatives

[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[vinelab/http

An http library developed for the laravel framework. aliases itself as HttpClient

59302.6k11](/packages/vinelab-http)[laragear/api-manager

Manage multiple REST servers to make requests in few lines and fluently.

162.2k](/packages/laragear-api-manager)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
