PHPackages                             perimeter/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. [API Development](/categories/api)
4. /
5. perimeter/rate-limit-bundle

ActiveSymfony-bundle[API Development](/categories/api)

perimeter/rate-limit-bundle
===========================

Perimeter RateLimitBundle

v0.1.7(11y ago)411.5k4MITPHPPHP &gt;=5.3.0

Since Oct 9Pushed 11y ago3 watchersCompare

[ Source](https://github.com/perimeter/RateLimitBundle)[ Packagist](https://packagist.org/packages/perimeter/rate-limit-bundle)[ Docs](http://github.com/perimeter/RateLimitBundle)[ RSS](/packages/perimeter-rate-limit-bundle/feed)WikiDiscussions develop Synced 1w ago

READMEChangelog (3)Dependencies (4)Versions (9)Used By (0)

Perimeter RateLimitBundle
=========================

[](#perimeter-ratelimitbundle)

[![Build Status](https://camo.githubusercontent.com/ef8c4914c73d9c1c2acefe28528c10d531d29079484e4057a51a4fe2f88e9387/68747470733a2f2f7472617669732d63692e6f72672f706572696d657465722f526174654c696d697442756e646c652e7376673f6272616e63683d646576656c6f70)](https://travis-ci.org/perimeter/RateLimitBundle)

Built on top of the stand-alone rate limiting library [rate-limiter-php](https://github.com/perimeter/rate-limiter-php)

Rate Limit those APIs!

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

[](#installation)

```
$ composer.phar require perimeter/rate-limit-bundle:dev-develop

```

Get Started
-----------

[](#get-started)

This library helps you rate limit your APIs in two ways:

- **Rate Limit Warning** - an `X-RATELIMIT-WARNING` header is issued in the response, but otherwise the call is unaffected.
- **Rate Limit Exceeded** - An HTTP status code of `429 Too Many Requests` is returned, and the call is throttled.

### Configure your Meter Storage

[](#configure-your-meter-storage)

The simplest option is to use `MemoryStorage` for meter configuration. Be default the warning header is issued at **80 calls/hour**, and the response is throttled at **100 calls/hour**. You can change these basic defaults in your service container:

```

    45000
    50000

```

This will now warn and limit your users at `45,000` and `50,000` calls per hour respectively. You can also customize different meters depending on the authenticated user:

```

            %perimeter.rate_limit.warn_threshold.default%
            %perimeter.rate_limit.limit_threshold.default%

            150
            200

```

This means any calls authenticated with the username `bshaffer` will get warned at `150/hr` and limited at `200/hr` instead of the default. If you plan on rate limiting by username, the `Doctrine Meter Storage` is highly recommended.

#### Doctrine Meter Storage (advanced)

[](#doctrine-meter-storage-advanced)

Doctrine meter storage is the best way to configure meters dynamically. First, run the command to create the tables in your database:

```
php vendor/doctrine/orm/bin/doctrine orm:schema-tool:update --force

```

Second, you will need to configure your container to use the doctrine storage engine:

```

```

Next, you'll want to create the meters in your doctrine database. Do this using the `perimeter:rate-limit-meter` command, for example:

```
$ ./bin/console perimeter:rate-limit-meter * 80 100

```

You *must* have a `default meter` configured when using Doctrine Meter Storage. The command above will create default meters which warn at `80 calls/hour`, and rate limit at `100 calls/hr`.

You can use the `perimeter:rate-limit-meter` command to view, create, update, and delete meters. There is also a `MeterApiController` that exposes a JSON/XML API to do this very thing.

### Configuring your Throttler

[](#configuring-your-throttler)

By default, this library uses the `RedisThrottler` for keeping track of hits and buckets. If `Redis` is not an option for throttling, you can use `DoctrineThrottler` for this as well, although this is not recommended as `Redis` is *much better suited* for this kind of thing.

#### Redis Throttler (default)

[](#redis-throttler-default)

This library uses Redis by default. To get started with the redis throttler, as long as redis is running on `localhost:6379`, you don't have to do anything! If your redis server is running somewhere else, just configure `perimeter.rate_limit.redis_client.url` in your container to point to the proper host and port.

#### Doctrine Throttler

[](#doctrine-throttler)

Be sure to run the following command to create the `rate_limit_bucket` table in your database:

```
php vendor/doctrine/orm/bin/doctrine orm:schema-tool:update --force

```

Now, configure your container to use `Perimeter\RateLimiter\Throttler\DoctrineThrottler` by making the throttler service ID an alias to the doctrine throttler:

```

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~26 days

Recently: every ~10 days

Total

8

Last Release

4054d ago

### Community

Maintainers

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

---

Top Contributors

[![bshaffer](https://avatars.githubusercontent.com/u/103941?v=4)](https://github.com/bshaffer "bshaffer (33 commits)")

---

Tags

apiratelimitapi-gatewayperimeter

### Embed Badge

![Health badge](/badges/perimeter-rate-limit-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/perimeter-rate-limit-bundle/health.svg)](https://phpackages.com/packages/perimeter-rate-limit-bundle)
```

###  Alternatives

[perimeter/rate-limiter-php

A very simple Rate Limiter for PHP

1715.4k1](/packages/perimeter-rate-limiter-php)

PHPackages © 2026

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