PHP code example of sagarkc / laravel-bot-throttle

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

    

sagarkc / laravel-bot-throttle example snippets


'channels' => array_merge(config('logging.channels'), config('botthrottle.log_channel')),

Route::middleware(['detect.bot', 'throttle.bot'])->group(function () {
    Route::get('/api/data', 'ApiController@getData');
});

return [
    'throttle' => [
        'max_attempts' => 100,
        'decay_minutes' => 1,
    ],
    'bot_detection' => [
        'user_agents' => [
            'curl', 'python', 'bot', 'spider', 'crawler', 'wget', 'httpclient', 'scrapy', 'axios'
        ],
        'ip_blacklist' => [],
        'log_bots' => true,
    ],
    'advanced' => [
        'log_all_bots' => true,
        'ban_duration_minutes' => 60,
        'block_response_code' => 403,
        'allow_whitelist_ips' => true,
        'whitelist_ips' => ['127.0.0.1'],
    ],
    'log_channel' => [
        'botthrottle' => [
            'driver' => 'single',
            'path' => storage_path('logs/botthrottle.log'),
            'level' => 'warning',
        ],
    ],
];

use BotThrottle\BotLog;

$blockedIps = BotLog::getBlockedIps();
bash
php artisan vendor:publish --provider="BotThrottle\BotThrottleServiceProvider"