PHP code example of missionx-co / laravel-prevent-duplicate-request

1. Go to this page and download the library: Download missionx-co/laravel-prevent-duplicate-request 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/ */

    

missionx-co / laravel-prevent-duplicate-request example snippets


// bootstrap/app.php
->withMiddleware(function (Middleware $middleware) {
    $middleware->api(append: [
        'preventDuplicateRequests'
    ]);
})

// app/Http/Kernel.php
protected $middlewareGroups = [
    'web' => [
        // ...
    ],

    'api' => [
        // ...
        'preventDuplicateRequests',
    ],
];

return [
    'key_algorithm' => \MissionX\LaravelPreventDuplicateRequest\UniqueKeyAlgorithms\RequestFingerprintGenerator::class,
];
bash
php artisan vendor:publish --tag="prevent-duplicate-request-config"