PHPackages                             fusonic/rate-limit-bundle - 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. fusonic/rate-limit-bundle

AbandonedArchivedSymfony-bundle[HTTP &amp; Networking](/categories/http)

fusonic/rate-limit-bundle
=========================

Simple rate limiting based on routes.

v4.0.0(5y ago)013.5k1[1 issues](https://github.com/fusonic/symfony-rate-limit-bundle/issues)MITPHPPHP &gt;=7.4

Since Jul 9Pushed 5y ago4 watchersCompare

[ Source](https://github.com/fusonic/symfony-rate-limit-bundle)[ Packagist](https://packagist.org/packages/fusonic/rate-limit-bundle)[ RSS](/packages/fusonic-rate-limit-bundle/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (15)Versions (6)Used By (0)

RateLimitBundle
===============

[](#ratelimitbundle)

This bundle provides simple rate limiting based on routes.

Getting started
---------------

[](#getting-started)

1. Install bundle:

```
composer require fusonic/rate-limit-bundle

```

2. Add RateLimitBundle to kernel:

```
    Fusonic\RateLimitBundle\RateLimitBundle::class => ['prod' => true],
```

3. Add cache config

```
framework:
    cache:
        app: cache.adapter.array
```

4. Add rate limit config

```
fusonic_rate_limit:
    cache_provider: "cache.app"
    enabled: true
    routes:
        foo:
            limit: 2
            period: 3600
```

How does it work
----------------

[](#how-does-it-work)

The bundle makes use of Symfony's event system. Therefore some events exist under `Fusonic/RateLimitBundle/Event`:

- **RateLimitAttemptsUpdatedEvent** will be emitted when a request for a rate limited route is detected.
- **RateLimitExceededEvent** will be emitted when a route limit is exceeded.
- **RateLimitResetAttemptsEvent** can be used to reset the state for a specific route (e.g. after a successful login)

### Example

[](#example)

Create an event listener or subscriber:

```
