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

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

amrachraf6699/laravel-idempotency-ledger
========================================

Conservative, database-backed HTTP idempotency for Laravel.

v0.1.0(today)00MITPHPPHP ^8.2CI failing

Since Aug 6Pushed todayCompare

[ Source](https://github.com/amrachraf6699/laravel-idempotency-ledger)[ Packagist](https://packagist.org/packages/amrachraf6699/laravel-idempotency-ledger)[ RSS](/packages/amrachraf6699-laravel-idempotency-ledger/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (9)Versions (2)Used By (0)

Laravel Idempotency Ledger
==========================

[](#laravel-idempotency-ledger)

Conservative, database-backed HTTP idempotency for Laravel 10–13 APIs. It prevents duplicate execution for a scoped `Idempotency-Key` and replays supported completed responses.

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

[](#installation)

```
composer require amrachraf6699/laravel-idempotency-ledger
php artisan vendor:publish --tag=idempotency-config
php artisan vendor:publish --tag=idempotency-migrations
php artisan migrate
```

Usage
-----

[](#usage)

Apply the `idempotent` middleware after authentication:

```
Route::post('/payments', StorePaymentController::class)
    ->middleware(['auth:sanctum', 'idempotent']);
```

Clients send one random key per logical operation:

```
Idempotency-Key: 0f8fad5b-d9cb-469f-a165-70867728950e
```

The package scopes keys to the authenticated identity by default. Public and multi-tenant APIs must provide a `ScopeResolver` in `config/idempotency.php`.

Behavior
--------

[](#behavior)

- Supported buffered 2xx–4xx responses are stored for 24 hours and replayed with `Idempotency-Replayed: true`.
- Reusing a key with a changed method, route, content type, or body returns `422`.
- A concurrent request returns `409` and `Retry-After: 1`.
- 5xx responses and unexpected exceptions become `indeterminate`; the package will not execute them again automatically.
- Throw `RetryableIdempotencyException` only when no irreversible side effect began. It returns `503`, and the next identical request may claim a new attempt.
- Streams, downloads, binary responses, oversized bodies, and undecryptable stored bodies are completed but non-replayable, so duplicate execution remains blocked.

Response bodies are encrypted using Laravel's encrypter. Set a dedicated, stable `IDEMPOTENCY_HASH_KEY` in production. Do not rotate that key while ledger records may still be queried.

Cleanup
-------

[](#cleanup)

Schedule `idempotency:prune`. It removes expired completed records and marks overdue processing claims as `indeterminate`; it never retries or removes indeterminate records.

```
Schedule::command('idempotency:prune')->daily();
```

Development
-----------

[](#development)

```
composer test
composer format
composer analyse
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/168471094?v=4)[Amr Achraf](/maintainers/amrachraf6699)[@amrachraf6699](https://github.com/amrachraf6699)

---

Top Contributors

[![amrachraf6699](https://avatars.githubusercontent.com/u/168471094?v=4)](https://github.com/amrachraf6699 "amrachraf6699 (6 commits)")

---

Tags

httpmiddlewarelaravelretryidempotency

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.4M352](/packages/psalm-plugin-laravel)[api-platform/laravel

API Platform support for Laravel

58174.6k18](/packages/api-platform-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

78727.1M206](/packages/laravel-mcp)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1239.7k25](/packages/fleetbase-core-api)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45844.8k1](/packages/pressbooks-pressbooks)[calebdw/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

16132.2k4](/packages/calebdw-larastan)

PHPackages © 2026

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