Download the PHP package truschery/idem without Composer
On this page you can find all versions of the php package truschery/idem. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download truschery/idem
More information about truschery/idem
Files in truschery/idem
Package idem
Short Description Idempotency for HTTP requests, queued jobs, and arbitrary operations
License MIT
Informations about the package idem
Ensures that repeating the same operation always produces the same result with no side effects. Essential for payment systems, APIs, and any operation where duplication is unacceptable.
Full documentation is available at idem.truschery.dev
Features
Idempotent— HTTP middleware: a repeated request with the sameIdempotency-Keyreturns the cached responseEnsureIdempotent— Job middleware: a queued job is executed only once, even if dispatched multiple timesOnce::do()— facade for arbitrary operations: any callable runs exactly once per key- Two storage drivers:
cacheanddatabase
Installation
Publish the configuration file:
If you plan to use the database driver, publish and run the migrations:
Usage
HTTP Requests — Idempotent
Register the middleware alias and apply it to a route or group:
The client sends a unique key in the request header:
A repeated request with the same key returns the stored response without re-executing the handler.
If the
Idempotency-Keyheader is absent, the request is processed normally — no error is thrown.
Queued Jobs — EnsureIdempotent
Pass the idempotency key directly to the middleware constructor:
Arbitrary Operations — Once::do()
A repeated call with the same key returns the cached result of the first execution.
Once::do() works in any context — HTTP requests, queued jobs, Artisan commands.
Roadmap
- [x] HTTP Middleware (
Idempotent) - [x] Job Middleware (
EnsureIdempotent) - [x]
Once::do()facade - [x]
cacheanddatabasedrivers - [x] Artisan command
idem:prune— removes expired records from the database - [ ] Extended tests for Job middleware and
Once::do()
License
MIT — see LICENSE for details.
All versions of idem with dependencies
illuminate/http Version *
illuminate/database Version *
illuminate/queue Version *
illuminate/cache Version *
illuminate/support Version *
truschery/kanon Version ^1.0