PHPackages                             alnoman141/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. alnoman141/laravel-idempotency

ActiveLibrary

alnoman141/laravel-idempotency
==============================

A robust idempotency and API reliability package for Laravel.

1.0.2(today)01↑2900%MITPHPPHP ^8.3

Since Jul 28Pushed todayCompare

[ Source](https://github.com/Alnoman141/laravel-idempotency)[ Packagist](https://packagist.org/packages/alnoman141/laravel-idempotency)[ RSS](/packages/alnoman141-laravel-idempotency/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (3)Used By (0)

Laravel Idempotency
===================

[](#laravel-idempotency)

![PHP](https://camo.githubusercontent.com/89899a77bdce65fc4c3d3423dfacff9c6461066a0b5354dc18d7721c23ba596e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e332532422d626c75652e737667)![Laravel](https://camo.githubusercontent.com/379ac210c7e2644180ddc1fb0ce39d8af7c51fdb8715c59570c4cf0da3403aa5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31332e782d7265642e737667)![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)

A lightweight and configurable Laravel package that provides **Idempotency-Key** support for APIs. It prevents duplicate requests by safely replaying previously stored responses.

Features
--------

[](#features)

- 🚀 Laravel 13 Support
- 🔒 Prevent duplicate API requests
- ⚡ Cache &amp; Database storage drivers
- 🔐 Request fingerprint validation
- 🔄 Response replay
- ⏳ Configurable TTL
- 🔒 Concurrency protection using cache locks
- 📢 Events
- 🛠 Artisan commands
- ✅ Pest test support

---

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 13.x

---

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

[](#installation)

Install via Composer:

```
composer require alnoman141/laravel-idempotency
```

---

Publish Configuration
---------------------

[](#publish-configuration)

```
php artisan vendor:publish --provider="alnoman141\LaravelIdempotency\IdempotencyServiceProvider" --tag=idempotency-config
```

This publishes:

```
config/idempotency.php

```

---

Publish Migration
-----------------

[](#publish-migration)

If you are using the **database** driver:

```
php artisan vendor:publish --provider="alnoman141\LaravelIdempotency\IdempotencyServiceProvider" --tag=migrations
```

Run the migration:

```
php artisan migrate
```

---

Configuration
-------------

[](#configuration)

Example:

```
return [

    'driver' => env('IDEMPOTENCY_DRIVER', 'cache'),

    'header' => 'Idempotency-Key',

    'ttl' => 3600,

];
```

Available drivers:

- `cache`
- `database`

---

Usage
-----

[](#usage)

Protect any route using the middleware.

```
Route::post('/orders', function () {

    return response()->json([
        'success' => true,
    ]);

})->middleware('idempotency');
```

Or specify a custom TTL:

```
Route::post('/orders', function () {

    //

})->middleware('idempotency:600');
```

---

Client Example
--------------

[](#client-example)

Include an **Idempotency-Key** header with every request.

```
POST /api/orders

Idempotency-Key: 550e8400-e29b-41d4-a716-446655440000
```

The same request using the same key will replay the original response instead of executing the request again.

---

Artisan Commands
----------------

[](#artisan-commands)

Clear stored idempotency records:

```
php artisan idempotency:clear
```

View statistics:

```
php artisan idempotency:stats
```

Remove expired records:

```
php artisan idempotency:prune
```

---

Events
------

[](#events)

The package dispatches the following events:

- `IdempotencyStarted`
- `IdempotencyCompleted`
- `IdempotencyReplayed`
- `IdempotencyConflictDetected`
- `IdempotencyFailed`

You can register your own listeners using Laravel's event system.

---

Testing
-------

[](#testing)

Run the test suite:

```
composer test
```

or

```
vendor/bin/pest
```

---

Best Practices
--------------

[](#best-practices)

- Generate a unique UUID for every write request.
- Never reuse an idempotency key for different payloads.
- Use the database driver for distributed applications.
- Configure a reasonable TTL based on your business requirements.

---

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

[](#contributing)

Contributions are welcome! Feel free to submit issues or pull requests.

---

License
-------

[](#license)

This package is open-sourced software licensed under the **MIT License**.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

2

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/210563132?v=4)[Alnoman1416](/maintainers/Alnoman1416)[@AlNoman1416](https://github.com/AlNoman1416)

---

Top Contributors

[![Alnoman141](https://avatars.githubusercontent.com/u/70745859?v=4)](https://github.com/Alnoman141 "Alnoman141 (10 commits)")

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M348](/packages/psalm-plugin-laravel)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M250](/packages/laravel-ai)[illuminate/filesystem

The Illuminate Filesystem package.

15265.2M3.3k](/packages/illuminate-filesystem)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)[tallstackui/tallstackui

TallStackUI is a powerful suite of Blade components that elevate your workflow of Livewire applications.

728176.2k14](/packages/tallstackui-tallstackui)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M292](/packages/illuminate-pipeline)

PHPackages © 2026

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