PHP code example of ez-php / idempotency
1. Go to this page and download the library: Download ez-php/idempotency library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ez-php / idempotency example snippets
use EzPhp\Idempotency\IdempotencyMiddleware;
$router->post('/orders', [OrderController::class, 'store'])
->middleware(IdempotencyMiddleware::class);
new IdempotencyMiddleware(
cache: $cache,
ttl: 86400, // seconds a response stays replayable
lockTtl: 30, // max seconds the in-flight lock is held
scope: fn (RequestInterface $r): string => (string) $userId, // optional key partition
);
bash
composer