PHP code example of setono / bot-detection-bundle
1. Go to this page and download the library: Download setono/bot-detection-bundle 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/ */
setono / bot-detection-bundle example snippets
return [
// ...
Setono\BotDetectionBundle\SetonoBotDetectionBundle::class => ['all' => true],
];
use Setono\BotDetectionBundle\BotDetector\BotDetectorInterface;
final class YourService
{
public function __construct(private readonly BotDetectorInterface $botDetector)
{
}
public function yourAction(string $userAgent): void
{
// Checks the user agent of the current main request
if ($this->botDetector->isBotRequest()) {
// do something to this bot!
}
// Checks a user agent string
if ($this->botDetector->isBot($userAgent)) {
// ...
}
}
}