承接 xqus/bad-bot 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xqus/bad-bot

最新稳定版本:v0.2.0-beta

Composer 安装命令:

composer require xqus/bad-bot

包简介

A lightweight package that blocks unwanted crawlers, AI agents, scrapers, and high‑frequency visitors while allowing legitimate bots such as Googlebot and Bingbot to pass.

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A lightweight package that blocks unwanted crawlers, AI agents, scrapers, and high‑frequency visitors while allowing legitimate bots such as Googlebot and Bingbot to pass.

Installation

You can install the package via composer:

composer require xqus/bad-bot

You can publish the config file with:

php artisan vendor:publish --tag="bad-bot-config"

Optionally, you can publish the views using

php artisan vendor:publish --tag="bad-bot-views"

Usage

Add the middelware you want to run to your bootstrap\app.php file (see the official documentation)

->withMiddleware(function (Middleware $middleware): void {
    $middleware->appendToGroup('web', [
        xqus\BadBot\Middleware\BadBotMiddleware::class, // blocks marked ip addresses
        xqus\BadBot\Middleware\ThrottleMiddleware::class, // blocks noisy bots, but allows whitelisted bots (Google, Bing, etc)
        xqus\BadBot\Middleware\UserAgentMiddleWare::class // blocks bots based on user-agent
    ]);
})

To build a new robots.txt run

php artisan badbot:update-txt

Be aware that this command overwrites your current public/robots.txt file.

Custom error handling

By default an exception extending Symfony\Component\HttpKernel\Exception\HttpException will be called when an request is blocked. This will render the default HTTP error page for that error code.

If you want to handle errors differently the following exceptions exists:

xqus\BadBot\Exceptions\RequestRateLimitedException
xqus\BadBot\Exceptions\UserAgentBlockedException
xqus\BadBot\Exceptions\IpAddressBlockedException

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-30