Download the PHP package alnoman141/laravel-idempotency without Composer
On this page you can find all versions of the php package alnoman141/laravel-idempotency. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alnoman141/laravel-idempotency
More information about alnoman141/laravel-idempotency
Files in alnoman141/laravel-idempotency
Package laravel-idempotency
Short Description A robust idempotency and API reliability package for Laravel.
License MIT
Informations about the package laravel-idempotency
Laravel Idempotency
[]()
[
]()
[
]()
A lightweight and configurable Laravel package that provides Idempotency-Key support for APIs. It prevents duplicate requests by safely replaying previously stored responses.
Features
- 🚀 Laravel 13 Support
- 🔒 Prevent duplicate API requests
- ⚡ Cache & Database storage drivers
- 🔐 Request fingerprint validation
- 🔄 Response replay
- ⏳ Configurable TTL
- 🔒 Concurrency protection using cache locks
- 📢 Events
- 🛠 Artisan commands
- ✅ Pest test support
Requirements
- PHP 8.3+
- Laravel 13.x
Installation
Install via Composer:
Publish Configuration
This publishes:
Publish Migration
If you are using the database driver:
Run the migration:
Configuration
Example:
Available drivers:
cachedatabase
Usage
Protect any route using the middleware.
Or specify a custom TTL:
Client Example
Include an Idempotency-Key header with every request.
The same request using the same key will replay the original response instead of executing the request again.
Artisan Commands
Clear stored idempotency records:
View statistics:
Remove expired records:
Events
The package dispatches the following events:
IdempotencyStartedIdempotencyCompletedIdempotencyReplayedIdempotencyConflictDetectedIdempotencyFailed
You can register your own listeners using Laravel's event system.
Testing
Run the test suite:
or
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
Contributions are welcome! Feel free to submit issues or pull requests.
License
This package is open-sourced software licensed under the MIT License.