PHPackages                             victorive/superban - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. victorive/superban

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

victorive/superban
==================

Easily ban your API clients for a specified period of time.

1.0.1(2y ago)16[2 PRs](https://github.com/victorive/superban/pulls)MITPHPPHP ^8.1

Since Dec 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/victorive/superban)[ Packagist](https://packagist.org/packages/victorive/superban)[ RSS](/packages/victorive-superban/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (7)Versions (5)Used By (0)

Superban
========

[](#superban)

[![Latest Version on Packagist](https://camo.githubusercontent.com/fd3f430c93066f51d682a39d2801fe73cf785c4d75096572c008a5d1b7ac3054/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f766963746f726976652f737570657262616e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/victorive/superban)

Superban is a Laravel package designed to enable you ban API clients for a specified period. It allows you to easily limit the number of requests a client can execute within a certain time frame, and if they surpass this limit, they will be banned for the specified duration.

Installation
------------

[](#installation)

Install the package via composer using:

```
composer require victorive/superban
```

Next, publish the configuration file `(config/superban.php)` with:

```
php artisan vendor:publish --tag="superban-config"
```

The published configuration file enables you to customize the `SUPERBAN_CACHE_DRIVER` and `SUPERBAN_BAN_CRITERIA`parameters for rate-limiting operations. These settings can be modified in your .env file with your preferred values.

If you choose to use the "database" as your cache driver, remember to run `php artisan cache:table` to create the necessary tables for the cache storage. See the [Cache](https://laravel.com/docs/10.x/cache#driver-prerequisites) docs for more info.

Configuration
-------------

[](#configuration)

- The `SUPERBAN_CACHE_DRIVER` parameter determines the cache driver used for Superban operations. Supported drivers include `"array", "database", "file", "memcached", "redis", "dynamodb", and "octane".`
- The `SUPERBAN_BAN_CRITERIA` parameter sets the criteria for rate-limiting or banning users.
- Supported options include `"user_id", "email", and "ip"`.

Example configuration:

```
return [
    /**
     * The cache driver to use for superban operations.
     *
     * Supported drivers: "array", "database", "file",
     * "memcached", "redis", "dynamodb", "octane"
     */
    'cache_driver' => env('SUPERBAN_CACHE_DRIVER', 'file'),

    /**
     * The ban criteria to use when rate-limiting/banning users.
     *
     * Supported options: "user_id", "email", "ip",
     */
    'ban_criteria' => env('SUPERBAN_BAN_CRITERIA', 'ip'),
];
```

Update your `.env` file with your preferred values for the keys below:

> SUPERBAN\_CACHE\_DRIVER= {{your preferred cache driver}}
>
> SUPERBAN\_BAN\_CRITERIA= {{your preferred ban criteria}}

Usage
-----

[](#usage)

To utilize Superban's functionalities, add the following to your `app/Http/Kernel.php` file.

```
protected $middlewareAliases = [
    // ...
    'superban' => \Victorive\Superban\Middleware\SuperbanMiddleware::class,
];
```

Then you can protect your routes using the middleware rules. For instance

- **Route group:**

```
Route::middleware(['superban:100,2,720'])->group(function () {
   Route::post('/someroute', function () {
       // ...
   });

   Route::post('anotherroute', function () {
       // ...
   });
});
```

- **Single route:**

```
Route::post('/thisroute', function () {
    // ...
})->middleware(['superban:100,2,720']);
```

In the examples above,

- **100** is the maximum number of requests allowed,
- **2** is the time period (in minutes) during which these requests can occur, and
- **720** is the duration (in minutes) for which the user will be banned after exceeding the limit.

Testing
-------

[](#testing)

To run the tests, use the following command:

```
vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

For information on recent updates, refer to the [CHANGELOG](CHANGELOG.md) file.

Contributing
------------

[](#contributing)

Contributions are welcome! Feel free to fork the repo, make any changes or report any issues, and submit a PR.

License
-------

[](#license)

This package is licensed under the MIT License. For more information, please see the [License File](LICENSE.md).

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

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

924d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/aad2b6e478f9cd2037c8f09b9efd2814c582093d4dbcffe9fd07c61d708b1f5f?d=identicon)[victorive](/maintainers/victorive)

---

Top Contributors

[![victorive](https://avatars.githubusercontent.com/u/45353611?v=4)](https://github.com/victorive "victorive (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (2 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

---

Tags

laravelSuperbanvictorive

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/victorive-superban/health.svg)

```
[![Health](https://phpackages.com/badges/victorive-superban/health.svg)](https://phpackages.com/packages/victorive-superban)
```

###  Alternatives

[directorytree/ldaprecord-laravel

LDAP Authentication &amp; Management for Laravel.

5752.3M18](/packages/directorytree-ldaprecord-laravel)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[hasinhayder/tyro

Tyro - The ultimate Authentication, Authorization, and Role &amp; Privilege Management solution for Laravel 12 &amp; 13

6783.6k6](/packages/hasinhayder-tyro)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1563.0k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

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