Skip to content

v6.0.0

Choose a tag to compare

@MoamenEltouny MoamenEltouny released this 23 Nov 21:13
· 8 commits to 6.x since this release

The first release of Laravel API Idempotency, on the Laravel 6 line: opt-in HTTP idempotency for Laravel routes, with fail-closed recovery.

What's included

  • One route macro: Route::post(...)->idempotent(), also on Route::resource() and apiResource(), and the idempotent middleware alias with an optional ttl. Routes stay compatible with route:cache.
  • The Idempotency-Key contract: keys of 1 to 255 visible ASCII characters, scoped per principal through a ScopeResolver (the authenticated user by default), with request fingerprints of the method, path, query string and JSON body through pharaonic/php-fingerprint.
  • Atomic reservation in the database (a unique insert, with a publishable migration) or Redis (Lua scripts, phpredis and predis).
  • Exact replay of 2xx JSON or empty responses with their safe headers and Idempotency-Replayed: true; other 4xx responses release the key.
  • Fail closed: server errors, exceptions, unstorable responses, abandoned leases and store outages never lead to a second run. Refused requests throw IdempotencyException with a stable error code.
  • IdempotentRequestReserved, IdempotentRequestReplayed, IdempotentRequestRejected and IdempotentRequestUnresolved events, and the idempotency:prune command. Logs never carry the client's key, the user or the body.

Requirements

6.0.0
PHP 8.0
Laravel 6.20+

Full Changelog: https://github.com/Pharaonic/laravel-api-idempotency/commits/6.0.0