Download the PHP package adilazhari/laravel-idempotency without Composer

On this page you can find all versions of the php package adilazhari/laravel-idempotency. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-idempotency

Laravel Idempotency

Framework-native HTTP idempotency for Laravel applications.

[![Tests](https://github.com/AdilAzhari/laravel-idempotency/actions/workflows/tests.yml/badge.svg)](https://github.com/AdilAzhari/laravel-idempotency/actions/workflows/tests.yml) ![PHP](https://img.shields.io/badge/PHP-8.5+-777BB4) ![Laravel](https://img.shields.io/badge/Laravel-13.x-FF2D20) ![License](https://img.shields.io/github/license/AdilAzhari/laravel-idempotency)


Why Another Idempotency Package?

Laravel applications commonly implement idempotency in an ad-hoc manner, often coupling request replay, persistence, and locking into application code.

Laravel Idempotency provides a reusable, framework-native solution built around explicit contracts and interchangeable components, allowing storage, fingerprinting, and locking strategies to evolve independently.

Laravel Idempotency

Laravel Idempotency provides a framework-native solution for ensuring that identical HTTP requests are executed exactly once.

Using an Idempotency-Key, the package stores the original HTTP response and automatically replays it for subsequent identical requests, eliminating accidental duplicate operations caused by retries or network failures.

It is particularly useful for:


Why Idempotency?

Distributed systems are unreliable.

Clients retry requests.

Browsers retry requests.

Mobile applications automatically retry after network interruptions.

Load balancers and reverse proxies may resend requests.

Without idempotency, a single retry can unintentionally create duplicate:

Laravel Idempotency guarantees that the same logical operation executes only once while returning the original response for every identical retry.


Features


Requirements

For production deployments, use a shared storage backend such as Redis or the Database driver.


Installation

Install the package using Composer.

Laravel automatically discovers the package.

Publish the configuration file:

If you intend to use the database storage driver, also publish the migration:


Quick Start

Protect any write endpoint using the middleware.

Clients simply provide an idempotency key.

The first request executes normally.

Subsequent identical requests return the previously stored response without executing the controller again.


How It Works


Request Matching

Two requests are considered identical when all of the following match:

The default implementation uses the built-in Sha256RequestFingerprinter.

For example:

and

are treated as different requests, even if they share the same idempotency key.

If the same key is reused for different request data, an IdempotencyConflictException is thrown and rendered as a 409 Conflict JSON response.


Error Responses

Situation Exception Status
Same key reused with different request data IdempotencyConflictException 409 Conflict
Another request with the same key is still in flight IdempotencyLockConflictException 409 Conflict
Idempotency key exceeds key_max_length InvalidIdempotencyKeyException 400 Bad Request

All three exceptions are self-rendering, so no custom exception handler registration is required.

JobIdempotencyMiddleware throws the equivalent plain exceptions for jobs — JobIdempotencyConflictException and JobIdempotencyLockConflictException — which are not self-rendering, since a queue worker has no HTTP response to render.


Jobs

Idempotency isn't only an HTTP concern. Laravel's own ShouldBeUnique/WithoutOverlapping prevent concurrent duplicate dispatch, but they don't protect against a job's side effects running twice after a retry-following-partial-success, an at-least-once queue redelivery, or two separate dispatches of the same logical action (e.g. a webhook retried by its sender).

JobIdempotencyMiddleware protects a job's side effects the same way IdempotencyMiddleware protects HTTP responses: a stable key, atomic locking, and a persisted record so a duplicate execution is skipped rather than re-run.

If the same key is later reused for a job with a different payload, a JobIdempotencyConflictException is thrown — the job-side equivalent of IdempotencyConflictException.


Connecting an HTTP Request to the Job It Dispatches

IdempotencyContext lets a job adopt the idempotency key of the HTTP request that triggered it, so one key protects both layers.

IdempotencyContext::current() returns the key from the current HTTP request when one was processed by IdempotencyMiddleware, or null outside of a request — falling back to your own key is always recommended.


Storage Drivers

Laravel Idempotency supports multiple persistence backends.

Driver Recommended Usage
Array Testing
Cache Default
Redis Distributed applications
Database Durable persistence

Select the active driver through configuration.

Switching drivers requires no application code changes.


Configuration

Option Description
driver Active storage driver
header HTTP header containing the idempotency key
methods HTTP methods the middleware applies to. An empty array applies it to every method.
key_max_length Maximum allowed length of an idempotency key before a 400 is returned
replay_header Response header set to true/false indicating a replayed vs. fresh response. Set to null to disable
lock.seconds Maximum lock duration
expiration Lifetime of stored responses
jobs.driver Storage driver used by JobIdempotencyMiddleware. Defaults to the same driver as driver
jobs.expiration Lifetime of stored job records

The lock duration should comfortably exceed the execution time of your protected endpoints.

Extending

Laravel Idempotency is built around a small set of contracts, allowing individual components to be replaced without modifying the package.

Custom Request Fingerprinting

Bind your own implementation of the RequestFingerprinter contract.

Possible use cases include:


Custom Storage

Implement the IdempotencyStore contract to persist responses anywhere.

Possible implementations include:


Custom Locking

Locking is also replaceable.

This allows integration with:


Storage Drivers

Cache Driver

The Cache driver is the default storage implementation.

It stores responses using Laravel's configured cache store and is suitable for most applications.


Array Driver

The Array driver stores responses in memory.

This driver is intended for:

Because data exists only in memory, it should not be used in production.


Redis Driver

The Redis driver stores responses directly in Redis.

Configuration:

This driver is recommended for distributed deployments where multiple application instances must share idempotency records.


Database Driver

The Database driver persists responses using Eloquent.

Before using it, publish the migration:

The database driver provides durable storage that survives cache flushes and application restarts.


Pruning Expired Records

Expired database records can be removed using the built-in Artisan command.

Scheduling the command is recommended.


Design Principles

Laravel Idempotency is intentionally built around a small set of principles.


Testing

Run the complete test suite.

The package includes comprehensive unit and feature tests covering:


Documentation

Additional documentation is available in the docs directory.


Roadmap


Contributing

Contributions are welcome.

If you discover a bug or would like to propose a new feature, please open an issue before submitting a pull request so the implementation can be discussed first.

When contributing:


License

Laravel Idempotency is open-source software licensed under the MIT License.


All versions of laravel-idempotency with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5.0
illuminate/cache Version ^13.0
illuminate/config Version ^13.0
illuminate/contracts Version ^13.0
illuminate/http Version ^13.0
illuminate/support Version ^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package adilazhari/laravel-idempotency contains the following files

Loading the files please wait ...