PHP code example of harmlessprince / superban

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

    

harmlessprince / superban example snippets




return [
    /*
    |--------------------------------------------------------------------------
    | Default Cache-Store
    |--------------------------------------------------------------------------
    |
    | This option controls the default cache connection that gets used while
    | using this caching library in superban. This connection is used when another is
    | not explicitly specified when executing a given caching function within the superban        libary.
    |
    | ** All laravel cache stores are supported **
    |
    */
    'cache_manager' => env('SUPER_BAN_CACHE_DRIVER', 'file'),

    /*
   |--------------------------------------------------------------------------
   | Default Request Key
   |--------------------------------------------------------------------------
   |
   | This option controls the default request key that gets used to
   | identify the client accessing your server.
   | Supported request keys are: "id"(if user is authenticated), "email"(if user is              authenticated), "ip"
   |
   |
   */
    'default_request_key' => env('SUPER_BAN_DEFAULT_REQUEST_KEY', 'ip'),
];



Route::middleware('superban')->get('/user', function (Request $request) {
     return ["hello" => 'World'];
});



Route::get('/jane', function (Request $request) {
    return ["hello" => 'World'];
})->middleware('superban:200,2,60');


Route::middleware(['superban:200,2,1440])->group(function () {
   Route::post('/thisroute', function () {
       // ...
   });
 
   Route::post('anotherroute', function () {
       // ...
   });
});
bash
php artisan vendor:publish --provider="Harmlessprince\SuperBan\SuperBanServiceProvider" --tag=superban-config