PHPackages                             jacksmall/laravel-ratelimiter - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. jacksmall/laravel-ratelimiter

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jacksmall/laravel-ratelimiter
=============================

Laravel Rate Limiter

v1.0.0(1y ago)10MITPHP

Since Jun 6Pushed 1y agoCompare

[ Source](https://github.com/Jacksmall/laravel-ratelimiter)[ Packagist](https://packagist.org/packages/jacksmall/laravel-ratelimiter)[ RSS](/packages/jacksmall-laravel-ratelimiter/feed)WikiDiscussions main Synced today

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

Laravel Rate Limiter
====================

[](#laravel-rate-limiter)

---

### 1.安装

[](#1安装)

```
composer require jacksmall/laravel-ratelimiter
```

### 2.配置

[](#2配置)

在 config/app.php 中添加服务提供者：

```
'providers' => [
    // ...
    Jacksmall\LaravelRatelimiter\Providers\RateLimiterServiceProvider::class,
],

'aliases' => [
    // ...
    'RateLimiter' => Jacksmall\LaravelRatelimiter\Facades\RateLimiter::class,
],
```

### 3.发布配置文件

[](#3发布配置文件)

```
php artisan vendor:publish --provider="Jacksmall\LaravelRatelimiter\Providers\RateLimiterServiceProvider" --tag='rate-limiter-config'
```

### 4.使用

[](#4使用)

在控制器中使用

```
use RateLimiter;

public function processPayment(Request $request)
{
    // 检查支付服务限流
    if (!RateLimiter::tryAcquire('service', 'payment-gateway')) {
        abort(429, 'Too many payment requests');
    }

    // 处理支付逻辑
    // ...
}
```

在路由中使用服务器端限流

```
use Jacksmall\LaravelRatelimiter\Http\Middleware\ServerRateLimiter;

Route::middleware([
    ServerRateLimiter::class . ':service,payment-gateway,2'
])->group(function () {
    Route::post('/payments', 'PaymentController@process');
});
```

在HTTP客户端中使用

```
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use Jacksmall\LaravelRatelimiter\Http\Middleware\ClientRateLimiter;

$handlerStack = HandlerStack::create();
$handlerStack->push(new ClientRateLimiter());

$client = new Client([
    'handler' => $handlerStack,
    'base_uri' => 'https://api.example.com'
]);

try {
    $response = $client->get('/data');
} catch (RateLimitExceededException $e) {
    // 处理限流异常
}
```

enjoy it!😄
----------

[](#enjoy-it)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance47

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

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

393d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12547809?v=4)[阿宽](/maintainers/Jacksmall)[@Jacksmall](https://github.com/Jacksmall)

### Embed Badge

![Health badge](/badges/jacksmall-laravel-ratelimiter/health.svg)

```
[![Health](https://phpackages.com/badges/jacksmall-laravel-ratelimiter/health.svg)](https://phpackages.com/packages/jacksmall-laravel-ratelimiter)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

674146.0k6](/packages/spatie-laravel-export)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5021.9k](/packages/simplestats-io-laravel-client)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k20](/packages/fleetbase-core-api)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[api-platform/laravel

API Platform support for Laravel

58171.6k14](/packages/api-platform-laravel)

PHPackages © 2026

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