PHP code example of alnoman141 / laravel-idempotency

1. Go to this page and download the library: Download alnoman141/laravel-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/ */

    

alnoman141 / laravel-idempotency example snippets


return [

    'driver' => env('IDEMPOTENCY_DRIVER', 'cache'),

    'header' => 'Idempotency-Key',

    'ttl' => 3600,

];

Route::post('/orders', function () {

    return response()->json([
        'success' => true,
    ]);

})->middleware('idempotency');

Route::post('/orders', function () {

    //

})->middleware('idempotency:600');
bash
php artisan vendor:publish --provider="alnoman141\LaravelIdempotency\IdempotencyServiceProvider" --tag=idempotency-config

config/idempotency.php
bash
php artisan vendor:publish --provider="alnoman141\LaravelIdempotency\IdempotencyServiceProvider" --tag=migrations
bash
php artisan migrate
bash
php artisan idempotency:clear
bash
php artisan idempotency:stats
bash
php artisan idempotency:prune