PHPackages                             areia-lab/laravel-traffic-control - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. areia-lab/laravel-traffic-control

ActiveLibrary[HTTP &amp; Networking](/categories/http)

areia-lab/laravel-traffic-control
=================================

Traffic control toolkit for Laravel — advanced throttling, blocking, bot detection, analytics, and dashboard.

1.0.1(8mo ago)05MITBladePHP &gt;=8.0

Since Sep 11Pushed 8mo agoCompare

[ Source](https://github.com/areia-lab/laravel-traffic-control)[ Packagist](https://packagist.org/packages/areia-lab/laravel-traffic-control)[ RSS](/packages/areia-lab-laravel-traffic-control/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Laravel Traffic Control 🚦
=========================

[](#laravel-traffic-control-)

[![Packagist Version](https://camo.githubusercontent.com/9d620a5539657644de4d78724094a227a834795ec482bf524eeb1022efa7e438/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61726569612d6c61622f6c61726176656c2d747261666669632d636f6e74726f6c)](https://camo.githubusercontent.com/9d620a5539657644de4d78724094a227a834795ec482bf524eeb1022efa7e438/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61726569612d6c61622f6c61726176656c2d747261666669632d636f6e74726f6c)[![Packagist Downloads](https://camo.githubusercontent.com/ca4c3ca7882bc8218af79c5b02743ad6d719bd93c15b12109f01ad36be99e1c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61726569612d6c61622f6c61726176656c2d747261666669632d636f6e74726f6c)](https://camo.githubusercontent.com/ca4c3ca7882bc8218af79c5b02743ad6d719bd93c15b12109f01ad36be99e1c9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61726569612d6c61622f6c61726176656c2d747261666669632d636f6e74726f6c)[![License](https://camo.githubusercontent.com/5b138f27811395a7247c80ed8ea9e78982efa105099d562dca959a862b6dc767/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61726569612d6c61622f6c61726176656c2d747261666669632d636f6e74726f6c)](https://camo.githubusercontent.com/5b138f27811395a7247c80ed8ea9e78982efa105099d562dca959a862b6dc767/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f61726569612d6c61622f6c61726176656c2d747261666669632d636f6e74726f6c)

A full-featured **traffic control &amp; security toolkit** for Laravel.
It provides **rate limiting, IP black/whitelisting, bot detection, request quotas, alerts, logging, and a monitoring dashboard**.

---

✨ Features
----------

[](#-features)

- 🔒 **Advanced Rate Limiting** (per-IP, per-user, per-route, per-role, per-plan)
- 🌍 **IP Control**: Whitelist, Blacklist, TOR/VPN blocking
- 🤖 **Bot &amp; Crawler Detection** using User-Agent patterns
- 📊 **Traffic Dashboard**: Visualize blocked/allowed requests
- 📑 **Logging** of suspicious/blocked requests with purge command
- 🔔 **Alerts** (Slack, Email) on suspicious spikes
- 🚦 **API Quotas** (daily, monthly, per-user, per-plan)
- 🧩 **Custom Rules**: Extend with your own blocking logic (GeoIP, maintenance windows, etc.)
- ⚡ **Request Queueing** (optional future feature)

---

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

[](#-installation)

Install via Composer:

```
composer require areia-lab/laravel-traffic-control
```

Publish configuration and migrations:

```
php artisan vendor:publish --provider="AreiaLab\TrafficControl\TrafficControlServiceProvider" --tag="traffic-config"
php artisan vendor:publish --provider="AreiaLab\TrafficControl\TrafficControlServiceProvider" --tag="traffic-migrations"
php artisan migrate
```

(Optional) Publish dashboard views:

```
php artisan vendor:publish --provider="AreiaLab\TrafficControl\TrafficControlServiceProvider" --tag="traffic-views"
```

---

📸 Screenshots
-------------

[](#-screenshots)

[![Dashboard](./public/images/dashboard.png)](./public/images/dashboard.png)[![Manage IP](./public/images/manage-ip.png)](./public/images/manage-ip.png)[![Settings](./public/images/settings.png)](./public/images/settings.png)

---

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

[](#️-configuration)

Edit `config/traffic.php`:

```
return [
    'enabled' => env('TRAFFIC_CONTROL_ENABLED', true), // Enable/disable globally
    'storage' => env('TRAFFIC_CONTROL_STORAGE', 'redis'), // redis | database | file

    'rate_limits' => [
        'default' => ['requests' => 60, 'per' => 60],
        'api' => ['requests' => 120, 'per' => 60],
    ],

    'ip' => [
        'block_tor' => true,
        'blacklist' => [],
        'whitelist' => [],
    ],

    'bot_detection' => [
        'enabled' => true,
        'user_agents' => ['bad-bot'],
    ],

    'alerts' => [
        'slack' => env('TRAFFIC_CONTROL_SLACK_WEBHOOK'),
        'email' => env('TRAFFIC_CONTROL_ALERT_EMAIL', 'admin@example.com'),
        'threshold' => env('TRAFFIC_CONTROL_ALERT_THRESHOLD', 1000),
    ],

    'dashboard' => [
        'enabled' => true,
        'prefix' => 'traffic-control',
        'middleware' => ['web'],
    ],

    'api_quota' => [
        'default' => 10000,
    ],

    'logging' => [
        'log_blocked' => true,
        'log_sample_rate' => 1,
    ],
];
```

---

🚀 Usage
-------

[](#-usage)

### Middleware

[](#middleware)

Apply globally in `app/Http/Kernel.php` or per route:

```
Route::middleware(['traffic.control'])->group(function () {
    Route::get('/api/data', [ApiController::class, 'index']);
});
```

Custom per-route limit:

```
Route::get('/heavy', [HeavyController::class, 'index'])
    ->middleware('traffic.control:200,60');
```

### Role/Plan-Based Limits

[](#roleplan-based-limits)

```
if ($user = $request->user()) {
    $plan = $user->plan ?? 'free';
    $limit = config("traffic-control.rate_limits.$plan", config('traffic-control.rate_limits.default'));
}
```

### API Quotas

[](#api-quotas)

```
use AreiaLab\TrafficControl\Facades\TrafficManager;

if (!TrafficManager::checkQuota($user->id)) {
    return response()->json(['error' => 'API quota exceeded'], 429);
}
```

### Dashboard

[](#dashboard)

```
Route::get('/admin/traffic', function () {
    $logs = \AreiaLab\TrafficControl\Models\TrafficLog::latest()->limit(50)->get();
    return view('vendor.traffic-control.dashboard', compact('logs'));
})->middleware(['web', 'auth'])->name('traffic-control.dashboard');
```

### Alerts

[](#alerts)

Set `.env` variables:

```
TRAFFIC_CONTROL_SLACK_WEBHOOK=https://hooks.slack.com/services/XXXX
TRAFFIC_CONTROL_ALERT_EMAIL=admin@example.com

```

### Purging Logs

[](#purging-logs)

```
php artisan traffic-control:purge               # Purge logs older than 30 days
php artisan traffic-control:purge --days=90 --force
php artisan traffic-control:purge --all
php artisan traffic-control:purge --all --force
```

---

🧩 Extending
-----------

[](#-extending)

Create custom rules under `src/Rules/`:

```
namespace AreiaLab\TrafficControl\Rules;

use Illuminate\Http\Request;

class GeoBlockRule
{
    public function handle(Request $request)
    {
        $country = $this->lookupCountry($request->ip());
        if (in_array($country, ['CN', 'RU'])) {
            return response('Not available in your region', 403);
        }
        return true;
    }

    protected function lookupCountry($ip)
    {
        return 'US';
    }
}
```

---

🛠 Roadmap
---------

[](#-roadmap)

- Redis sliding window / leaky bucket limiter
- GeoIP/TOR/VPN detection integration
- Charts for dashboard
- Plan-based quota &amp; billing hooks
- AI anomaly detection

---

🤝 Contributing
--------------

[](#-contributing)

PRs are welcome!

- Follow **PSR-12** coding style
- Add **unit/feature tests**
- Update **README.md** when adding new features

---

📜 License
---------

[](#-license)

MIT © AreiaLab

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance61

Regular maintenance activity

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.3% 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

Every ~0 days

Total

2

Last Release

244d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d954a36b146e87dd3f3c8e05e2e174daec70883c5ada3ad2f572016fcea3fc3?d=identicon)[areiatech](/maintainers/areiatech)

---

Top Contributors

[![engr-akramulhoque](https://avatars.githubusercontent.com/u/116001734?v=4)](https://github.com/engr-akramulhoque "engr-akramulhoque (26 commits)")[![areiatech](https://avatars.githubusercontent.com/u/142617586?v=4)](https://github.com/areiatech "areiatech (6 commits)")

### Embed Badge

![Health badge](/badges/areia-lab-laravel-traffic-control/health.svg)

```
[![Health](https://phpackages.com/badges/areia-lab-laravel-traffic-control/health.svg)](https://phpackages.com/packages/areia-lab-laravel-traffic-control)
```

###  Alternatives

[danharrin/livewire-rate-limiting

Apply rate limiters to Laravel Livewire actions.

40423.1M27](/packages/danharrin-livewire-rate-limiting)[mateusjunges/laravel-kafka

A kafka driver for laravel

7163.1M17](/packages/mateusjunges-laravel-kafka)[illuminate/http

The Illuminate Http package.

11936.0M5.1k](/packages/illuminate-http)[ricorocks-digital-agency/soap

A SOAP client that provides a clean interface for handling requests and responses.

4281.8M5](/packages/ricorocks-digital-agency-soap)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[laravel-shift/curl-converter

A command line tool to convert curl requests to Laravel HTTP requests.

935.3k](/packages/laravel-shift-curl-converter)

PHPackages © 2026

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