setono/bot-detection-bundle
最新稳定版本:v1.13.0
Composer 安装命令:
composer require setono/bot-detection-bundle
包简介
A Symfony bundle that allows you to test if a user agent is a bot
README 文档
README
Detect if the user agent is a bot and act upon it. Under the hood this bundle uses the matomo-org/device-detector, but instead of just using that library this library has a very small subset of user agents that it checks first (i.e. major search engines). This makes it much faster in detecting those very common bots and hence speeds up your request cycle.
Installation
composer require setono/bot-detection-bundle
This installs and enables the plugin automatically if you're using Symfony Flex. If not, add the bundle manually
to bundles.php.
Usage
You can use the bot detector in your services:
<?php use Setono\BotDetectionBundle\BotDetector\BotDetectorInterface; final class YourService { private BotDetectorInterface $botDetector; public function __construct(BotDetectorInterface $botDetector) { $this->botDetector = $botDetector; } public function yourAction(): void { if ($this->botDetector->isBotRequest()) { // do something to this bot! } // ... } }
and you can use it inside your twig templates:
{% if is_bot_request() %}
I knew you where a bot!
{% endif %}
统计信息
- 总下载量: 105.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 1
- 依赖项目数: 7
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-17