PHPackages                             balambasik/throttler - 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. balambasik/throttler

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

balambasik/throttler
====================

Throttle any operations

1.0.10(4y ago)09MITPHPPHP &gt;=7.2.0

Since Jan 18Pushed 4y ago1 watchersCompare

[ Source](https://github.com/balambasik/throttler)[ Packagist](https://packagist.org/packages/balambasik/throttler)[ RSS](/packages/balambasik-throttler/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (4)Used By (0)

Throttler - simple php library.

Designed to limit any action. Minimum configuration, maximum simplicity.

Works with MySql drivers and Memory. Add your driver, implement DriverInterface.

**Installation**

```
composer require balambasik/throttler

```

**One example of using**

```
$driver = new MySQLDriver("localhost", "root", "", "throttler", "throttler");
$factory = new ThrottlerFactory($driver);

$registerThrottler = $factory
                ->id($_SERVER["REMOTE_ADDR"])
                ->tag("/api/register")
                ->waitSeconds(5)
                ->create();

// 1 request per 5 seconds per IP, per route - "/api/register"
if($registerThrottler->isLimit()){
    exit("Limit!")
} else {
  // handle request
}

// or -------------------------------------

$registerThrottler->isLimit(function(){
    exit("Limit!")
});

// handle request
```

**Multiple instances**

```
// 1 request per 5 seconds per IP, per route - "/api/register"
$registerThrottler = $factory
                ->id($_SERVER["REMOTE_ADDR"])
                ->tag("/api/register")
                ->waitSeconds(5)
                ->create();

// 1 request per 1 minute per IP, per route - "/api/forgot_password"
$forgotThrottler = $factory
                ->id($_SERVER["REMOTE_ADDR"])
                ->tag("/api/forgot_password")
                ->waitMinutes(1)
                ->create();

$registerThrottler->isLimit(function(){
    exit("Limit!")
});

$forgotThrottler->isLimit(function(){
    exit("Limit!")
});
```

**Manual mode**

By default, method **isLimit()** logs a hit and checks if the limit has been reached. You can separate these operations.

```
// 1 request per 5 seconds per IP, per route - "/api/register"
$registerThrottler = $factory
                ->id($_SERVER["REMOTE_ADDR"])
                ->tag("/api/register")
                ->waitSeconds(5)
                ->createManualMode();

// set hit
$registerThrottler->hit();

// check limit
$registerThrottler->isLimit(function(){
    exit("Limit!")
});
```

The MySql driver needs a table.

```
CREATE TABLE IF NOT EXISTS `table_name` (
    `id` varchar(10),
    `tag` varchar(10),
    `wait` INT(11) UNSIGNED NOT NULL
    );

ALTER TABLE `table_name` ADD INDEX (`id`, `tag`);
```

Or call the **createTable()** method of the **MySqlDriver** object once

```
$MySQLDriver = new MySqlDriver("localhost", "login", "password", "dbName", "tableName");
$MySQLDriver->createTable();
```

**InMemory driver**

The **InMemoryDriver** does not require any configuration. For obvious reasons, it can persist state across requests. Therefore, protecting routes with it is a bad idea. It is great for limiting operations within a single request.

```
$driver = new InMemoryDriver();
$factory = new ThrottlerFactory($driver);
// ...
```

Licence - MIT.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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 ~2 days

Total

3

Last Release

1623d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f5fc50ac7072b6165334e76843485a39f09eea0ec10bd4895b5ea0af03b2d2b?d=identicon)[balambasik](/maintainers/balambasik)

---

Top Contributors

[![balambasik](https://avatars.githubusercontent.com/u/13239633?v=4)](https://github.com/balambasik "balambasik (3 commits)")

### Embed Badge

![Health badge](/badges/balambasik-throttler/health.svg)

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

###  Alternatives

[dmitryd/typo3-realurl

Speaking URLs for TYPO3

112911.2k9](/packages/dmitryd-typo3-realurl)

PHPackages © 2026

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