PHPackages                             generalfocus/limitshield - 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. [API Development](/categories/api)
4. /
5. generalfocus/limitshield

ActiveLibrary[API Development](/categories/api)

generalfocus/limitshield
========================

LimitShield is a middleware package designed to manage and enforce API rate limiting efficiently.

1.0.2(1y ago)181MITPHPPHP ^7.4|^8.0

Since Jun 10Pushed 1y ago1 watchersCompare

[ Source](https://github.com/GeneralFocus/LimitShield)[ Packagist](https://packagist.org/packages/generalfocus/limitshield)[ RSS](/packages/generalfocus-limitshield/feed)WikiDiscussions main Synced 1mo ago

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

LimitShield
-----------

[](#limitshield)

**LimitShield** is a Laravel middleware package designed to efficiently manage and enforce API rate limiting. It offers customizable rate limits, supports IP-based and user-based limiting, integrates seamlessly with Redis for distributed rate limiting, and provides flexibility in crafting responses for rate limit breaches.

### Features

[](#features)

- Configurable rate limits
- IP-based and user-based limiting
- Redis integration for distributed rate limiting
- Customizable responses for rate limit breaches

### Installation

[](#installation)

#### Requirements

[](#requirements)

- PHP ^7.4|^8.0
- Laravel ^8.0|^9.0|^10.0|^11.0
- Redis (for distributed rate limiting)

#### Step-by-Step Installation

[](#step-by-step-installation)

1. **Require the Package**

    Add `LimitShield` to your Laravel project using Composer:

    ```
    composer require generalfocus/limitshield:*
    ```
2. **Publish Configuration**

    Publish the configuration file to customize the settings:

    ```
    php artisan vendor:publish --provider="GeneralFocus\LimitShield\Providers\PackageServiceProvider" --tag="config"
    ```
3. **Configure Middleware**

    Add the `RateLimitMiddleware` to your HTTP kernel. Edit `app/Http/Kernel.php`:

    ```
    protected $routeMiddleware = [
        // Other middleware
        'rate.limit' => \GeneralFocus\LimitShield\Http\Middleware\RateLimitMiddleware::class,
    ];
    ```

### Usage

[](#usage)

#### Applying Middleware to Routes

[](#applying-middleware-to-routes)

You can apply the rate limit middleware to specific routes or route groups:

```
use Illuminate\Support\Facades\Route;

Route::middleware('rate.limit')->group(function () {
    Route::get('/api/resource', 'ApiResourceController@index');
});
```

Alternatively, you can apply the middleware directly in route definitions:

```
use Illuminate\Support\Facades\Route;

Route::get('/api/resource', 'ApiResourceController@index')->middleware('rate.limit:limit=100,duration=60');
```

#### Configuring Limits

[](#configuring-limits)

Edit the `config/limitshield.php` file to set your desired rate limits and other configurations:

```
return [
    'limits' => [
        'global' => [
            'enabled' => true,
            'max_requests' => 100,
            'decay_minutes' => 1,
        ],
        'ip' => [
            'enabled' => true,
            'max_requests' => 50,
            'decay_minutes' => 1,
        ],
        'user' => [
            'enabled' => true,
            'max_requests' => 200,
            'decay_minutes' => 1,
        ],
    ],
    'redis' => [
        'connection' => 'default',
    ],
    'response' => [
        'message' => 'Too many requests, please try again later.',
        'retry_after' => 'Retry-After',
    ],
];
```

### Contributing

[](#contributing)

#### Guidelines

[](#guidelines)

1. Fork the repository.
2. Create a new branch (`git checkout -b feature/YourFeature`).
3. Commit your changes (`git commit -am 'Add some feature'`).
4. Push to the branch (`git push origin feature/YourFeature`).
5. Create a new Pull Request.

This README provides comprehensive instructions on installing, configuring, and using LimitShield in your Laravel applications. Feel free to contribute to its development and improve its functionality!

```

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

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

3

Last Release

705d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/64069f499aaa29cd5f1168e7bbd13d2dc17cc69b70d2981dd207eb5adb95ecad?d=identicon)[Generalfocus](/maintainers/Generalfocus)

---

Top Contributors

[![GeneralFocus](https://avatars.githubusercontent.com/u/43112013?v=4)](https://github.com/GeneralFocus "GeneralFocus (21 commits)")[![Ghaniyyat05](https://avatars.githubusercontent.com/u/142936812?v=4)](https://github.com/Ghaniyyat05 "Ghaniyyat05 (1 commits)")

---

Tags

middlewareapilaravelrate limiting

### Embed Badge

![Health badge](/badges/generalfocus-limitshield/health.svg)

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

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[imliam/laravel-throttle-simultaneous-requests

Throttle the current user's requests based on how many requests are currently being executed.

4623.0k](/packages/imliam-laravel-throttle-simultaneous-requests)[specialtactics/l5-api

Dependencies for the Laravel API Boilerplate package

3672.8k2](/packages/specialtactics-l5-api)[shahghasiadil/laravel-api-versioning

Elegant attribute-based API versioning solution for Laravel applications with built-in deprecation management and version inheritance

2913.6k](/packages/shahghasiadil-laravel-api-versioning)

PHPackages © 2026

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