PHP code example of mkopcic / laravel-bot-protection
1. Go to this page and download the library: Download mkopcic/laravel-bot-protection 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/ */
mkopcic / laravel-bot-protection example snippets
// app/Providers/AppServiceProvider.php
use Illuminate\Support\Facades\Event;
use Mkopcic\BotProtection\Events\BotBlocked;
public function boot(): void
{
Event::listen(function (BotBlocked $event) {
// $event->userAgent — full UA string
// $event->ip — client IP
// $event->url — full URL the bot tried
// $event->matchedAgent — which needle from blocked_agents matched
\Log::channel('bots')->info('Blocked', (array) $event);
});
}