Download the PHP package bahadovic/laravel-idempotency without Composer

On this page you can find all versions of the php package bahadovic/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 Engine ๐Ÿš€

Latest Version on Packagist Total Downloads PHPStan Level 8

A production-grade, distributed idempotency engine for Laravel APIs. Designed for high-throughput systems, Fintech applications, and modern asynchronous Laravel runtimes (Octane, RoadRunner, Swoole).

Prevents duplicate ownership and stale-worker state commits within the idempotency state machine through atomic Compare-And-Swap (CAS) operations, lease expirations, and monotonic fencing tokens.


๐Ÿ”ฅ Features

  1. Deterministic State Machine: Requests strictly transition through No Record โž” PROCESSING โž” COMPLETED (or โ†˜ COMPLETED_NON_REPLAYABLE).
  2. Cryptographic Request Fingerprinting: Automatically hashes Method, Path, Body, and relevant Headers using SHA-256 to reject tampered payloads with 422 Unprocessable Entity.
  3. Atomic Concurrency: Smart WaitStrategy with exponential backoff with jitter and microsecond-precise timeout calculation.
  4. Stale Worker Protection (Fencing Tokens): Prevents delayed or zombie workers from committing stale responses after lease expiration.
  5. Octane & Long-Running Safe: Designed for long-running Laravel workers without request-scoped mutable state in the core engine.
  6. Native Request Scoping: Keys are logically isolated by authenticated user ID or guest IP, with support for custom Tenant/Resolver scopes.
  7. Safe Response Rehydration: Stores and replays actual HTTP Status Codes and Headers, whilst safely bypassing non-replayable streams.

๐Ÿ›ก๏ธ Architecture & Fencing

Provides atomic idempotency ownership transitions, lease-based recovery, and strict fencing protection against stale-worker database commits.

Execution & Failure Semantics

Important Note on External Side Effects: Idempotency record fencing strictly protects database state ownership and prevents duplicate response commits. External side effects (such as third-party payment gateways, dispatching emails, or remote queues) must independently support idempotency keys or be coordinated via transactional patterns (e.g., Transactional Outbox pattern).

๐Ÿ“ก Observability & Events

The engine dispatches lightweight domain events through Laravel's Event Dispatcher:

You can listen to these events in your EventServiceProvider:


๐Ÿ“ฆ Installation

Publish the configuration file and database migrations:


๐Ÿ’ก Usage

1. The Middleware Approach (Recommended)

Simply attach the idempotency middleware to your data-mutating routes (e.g., Checkout, Payments, Order creation):

Clients must include the Idempotency-Key header (e.g., a UUID or ULID) in their requests:

2. The Fluent Facade Approach

For programmatic control inside complex service classes:


โš™๏ธ Configuration (config/idempotency.php)

The package provides deep configurability out of the box:


๐Ÿงช Testing & Quality

This package is meticulously tested with an intense Domain-Driven Design (DDD) approach, covering state transitions, lease expiry, and concurrency fencing.


๐Ÿงน Retention & Cleanup


4xx Client Errors & 5xx Server Errors Handling


๐Ÿงฉ Compatibility

Package Laravel PHP
^1.0 10.x, 11.x, 12.x, 13.x 8.2+

๐Ÿ›๏ธ Architectural Decisions & FAQ

Why not use UPDATE ... RETURNING in the Database Store?

While engines like PostgreSQL, SQLite (3.35+), and MariaDB support RETURNING clauses, MySQL (up to 8.4 LTS) does not.

To maintain 100% native compatibility across all Laravel-supported database engines without introducing brittle driver-specific query branching or raw SQL dependencies, we perform a standard conditional UPDATE followed by a single row fetch. This deliberate engineering trade-off favors maintainability, safety, and universal compatibility across the entire Laravel ecosystem.


๐Ÿ“„ License

The MIT License (MIT). Please see License File for more information.



All versions of laravel-idempotency with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/redis Version ^10.0|^11.0|^12.0|^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 bahadovic/laravel-idempotency contains the following files

Loading the files please wait ...