PHP code example of victorive / superban

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

    

victorive / superban example snippets


return [
    /**
     * The cache driver to use for superban operations.
     *
     * Supported drivers: "array", "database", "file",
     * "memcached", "redis", "dynamodb", "octane"
     */
    'cache_driver' => env('SUPERBAN_CACHE_DRIVER', 'file'),

    /**
     * The ban criteria to use when rate-limiting/banning users.
     *
     * Supported options: "user_id", "email", "ip",
     */
    'ban_criteria' => env('SUPERBAN_BAN_CRITERIA', 'ip'),
];

protected $middlewareAliases = [
    // ...
    'superban' => \Victorive\Superban\Middleware\SuperbanMiddleware::class,
];

Route::middleware(['superban:100,2,720'])->group(function () {
   Route::post('/someroute', function () {
       // ...
   });
 
   Route::post('anotherroute', function () {
       // ...
   });
});

Route::post('/thisroute', function () {
    // ...
})->middleware(['superban:100,2,720']);
bash
php artisan vendor:publish --tag="superban-config"