PHPackages                             michaelesmith/throttle - 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. michaelesmith/throttle

ActiveLibrary

michaelesmith/throttle
======================

A basic throttling implementation

0.2.0(7y ago)62.4k2[1 PRs](https://github.com/michaelesmith/Throttle/pulls)MITPHPPHP ^7.1CI failing

Since Nov 3Pushed 6y ago2 watchersCompare

[ Source](https://github.com/michaelesmith/Throttle)[ Packagist](https://packagist.org/packages/michaelesmith/throttle)[ RSS](/packages/michaelesmith-throttle/feed)WikiDiscussions master Synced 1mo ago

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

[![Build Status](https://camo.githubusercontent.com/1ac91a33653a76f4fe2d0f1320dec050518278a5cea9edaeec211e904e664e2f/68747470733a2f2f7472617669732d63692e6f72672f6d69636861656c65736d6974682f5468726f74746c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/michaelesmith/Throttle)

What is it?
===========

[](#what-is-it)

A basic throttling implementation

Versions
========

[](#versions)

If you are looking for the old version compatible with PHP 5.3 try the [v0.1 branch](https://github.com/michaelesmith/Throttle/tree/v0.1) and update your composer requirement to `"michaelesmith/throttle": "^0.1"`

Installation
============

[](#installation)

`composer require "michaelesmith/throttle"`

You will also need a PSR-6 compatible cache library such as `"cache/cache"` or `"symfony/cache"`.

Examples
========

[](#examples)

```
$throttle = new Throttle(new \Cache\Adapter\PHPArray\ArrayCachePool());
$throttle->add(new Condition(60, 2)); // adds an interval where 2 increments are allowed in 60 seconds
$throttle->add(new Condition(600, 5)); // adds an interval where 5 increments are allowed in 10 minutes

// in each action you want to limit
try {
    $throttle->increment($_SERVER['REMOTE_ADDR']); // some client identifier like an ip or session id
    // NOTE: $_SERVER['REMOTE_ADDR'] may not gove you the actual client IP if you are behind a reverse proxy
    // Here is how Symfony finds the client IP
    // @link: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L786-L805
} catch(RateException $e) {
    $condition = $e->getCondition(); // the condition that hit the rate limit
    printf('You can only make %d requests in %d seconds', $condition->getLimit(), $condition->getTtl());
}
```

You can use any PSR-6 compatible cache pool, but you need to use one that is persistent across requests for most cases unlike this example.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% 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 ~2 days

Total

3

Last Release

2741d ago

PHP version history (2 changes)0.1PHP &gt;=5.3.2

0.2.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/02cd7a5417015ea4b37ad2b111bde525384de978cf5b2bbf9ef9080ac90342e5?d=identicon)[michaelesmith](/maintainers/michaelesmith)

---

Top Contributors

[![michaelesmith](https://avatars.githubusercontent.com/u/181546?v=4)](https://github.com/michaelesmith "michaelesmith (12 commits)")[![aitboudad](https://avatars.githubusercontent.com/u/1753742?v=4)](https://github.com/aitboudad "aitboudad (1 commits)")[![silvioq](https://avatars.githubusercontent.com/u/155036?v=4)](https://github.com/silvioq "silvioq (1 commits)")

---

Tags

throttle

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/michaelesmith-throttle/health.svg)

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

###  Alternatives

[graham-campbell/throttle

Throttle Is A Rate Limiter For Laravel

7102.3M11](/packages/graham-campbell-throttle)[davedevelopment/stiphle

Simple rate limiting/throttling for php

2567.7M9](/packages/davedevelopment-stiphle)[bandwidth-throttle/token-bucket

Implementation of the Token Bucket algorithm.

5121.9M10](/packages/bandwidth-throttle-token-bucket)[clue/mq-react

Mini Queue, the lightweight in-memory message queue to concurrently do many (but not too many) things at once, built on top of ReactPHP

144691.7k4](/packages/clue-mq-react)[api-platform/metadata

API Resource-oriented metadata attributes and factories

223.5M96](/packages/api-platform-metadata)[sunspikes/php-ratelimiter

A framework agnostic rate limiter for PHP

76674.1k1](/packages/sunspikes-php-ratelimiter)

PHPackages © 2026

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