PHPackages                             sagarkc/laravel-bot-throttle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. sagarkc/laravel-bot-throttle

ActiveLibrary[Security](/categories/security)

sagarkc/laravel-bot-throttle
============================

Advanced bot detection and request throttling package for Laravel by Sagar KC

v1.0.0(1y ago)01MITPHPPHP ^7.4|^8.0

Since May 23Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sagar720/laravel-bot-throttle)[ Packagist](https://packagist.org/packages/sagarkc/laravel-bot-throttle)[ RSS](/packages/sagarkc-laravel-bot-throttle/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

Laravel Bot Throttle by Sagar KC
================================

[](#laravel-bot-throttle-by-sagar-kc)

**Laravel Bot Throttle** is an advanced middleware package for Laravel to detect and block bots, throttle abuse, and protect your routes. Developed and maintained by **Sagar KC**

---

🚀 Features
----------

[](#-features)

- 🛡️ Detects bots based on User-Agent patterns
- ⛔ Temporarily bans malicious IPs via cache
- 📈 Logs bot activity to a dedicated log file (`botthrottle.log`)
- 🔄 Customizable request throttling per IP and route
- ⚙️ IP whitelisting and block control
- 🧩 Fully configurable via `config/botthrottle.php`

---

📦 Installation
--------------

[](#-installation)

```
composer require sagarkc/laravel-bot-throttle
```

---

🛠️ Publish the Config File
--------------------------

[](#️-publish-the-config-file)

```
php artisan vendor:publish --provider="BotThrottle\BotThrottleServiceProvider"
```

This will publish `config/botthrottle.php` which allows full customization, you can add the list of bots as per your need.

---

📝 Optional: Enable Custom Bot Log File
--------------------------------------

[](#-optional-enable-custom-bot-log-file)

To log bot activity in a separate file (`storage/logs/botthrottle.log`), add the following line to the `channels` array in your `config/logging.php` file:

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

This merges the custom `botthrottle` log channel defined in `config/botthrottle.php` into Laravel's logging system.

> After this, all blocked bots will be logged in `botthrottle.log` instead of the default `laravel.log`.

---

🧪 Usage
-------

[](#-usage)

Apply middleware to your routes:

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

---

⚙️ Configuration Example
------------------------

[](#️-configuration-example)

```
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',
        ],
    ],
];
```

---

📊 View Blocked IPs (Programmatically)
-------------------------------------

[](#-view-blocked-ips-programmatically)

```
use BotThrottle\BotLog;

$blockedIps = BotLog::getBlockedIps();
```

---

📄 License
---------

[](#-license)

MIT © [Sagar KC](https://sagarkc.com.np)

---

🙌 Contributing
--------------

[](#-contributing)

Pull requests and issues are welcome. Please fork the repository and open a PR with improvements or bug fixes.

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance46

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

408d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/23649370?v=4)[Sagar kc](/maintainers/sagar720)[@sagar720](https://github.com/sagar720)

---

Top Contributors

[![sagar720](https://avatars.githubusercontent.com/u/23649370?v=4)](https://github.com/sagar720 "sagar720 (3 commits)")

### Embed Badge

![Health badge](/badges/sagarkc-laravel-bot-throttle/health.svg)

```
[![Health](https://phpackages.com/badges/sagarkc-laravel-bot-throttle/health.svg)](https://phpackages.com/packages/sagarkc-laravel-bot-throttle)
```

###  Alternatives

[illuminate/encryption

The Illuminate Encryption package.

9630.7M327](/packages/illuminate-encryption)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
