Download the PHP package wendelladriel/laravel-idempotency without Composer
On this page you can find all versions of the php package wendelladriel/laravel-idempotency. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wendelladriel/laravel-idempotency
More information about wendelladriel/laravel-idempotency
Files in wendelladriel/laravel-idempotency
Package laravel-idempotency
Short Description HTTP Idempotency Middleware for Laravel applications
License MIT
Informations about the package laravel-idempotency
Laravel Idempotency
HTTP idempotency middleware for Laravel applicationsInstallation
You can install the package via composer:
You can publish the config file with:
Usage
Attach the middleware to routes that create or update data:
By default, the middleware reads the key from the Idempotency-Key header or the _idempotency_key request input. This allows standard HTML forms to include the key in a hidden input. When both values are present, the header takes precedence.
Use the @idempotency Blade directive to render the hidden input with a generated key:
You may pass an existing key with @idempotency($key).
When the same key is sent again with the same request data, the package replays the original response instead of executing your route again.
The HTTP middleware requires a cache driver that supports atomic locks. In multi-server deployments, every application server must use the same shared cache backend. The array driver is only suitable for tests or single-process development. See Laravel's atomic lock documentation for supported deployment options.
Streamed and binary file responses cannot be captured safely, so they are not cached. A repeated request with the same key executes the route again, and the response does not include an Idempotency-Replayed header.
Customize a single route with Idempotent::using:
The cacheStatuses option controls which response categories are stored: informational, success, redirection, client_error, and server_error. All are enabled by default; disabling one leaves the key free for a retry instead of replaying a stored failure.
You may also use the idempotent middleware alias:
If you prefer attributes, use the package's #[Idempotent] attribute on a controller class or method:
Generate a key in application code when needed:
Inspect and prune cached entries with the included Artisan commands:
Access the full documentation here.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Thank you for considering contributing to Laravel Idempotency! You can read the contribution guide here.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Wendell Adriel
- All Contributors
License
Laravel Idempotency is open-sourced software licensed under the MIT license.