PHPackages                             websoftwares/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. [Security](/categories/security)
4. /
5. websoftwares/throttle

ActiveLibrary[Security](/categories/security)

websoftwares/throttle
=====================

Ban identifier after certain amount of requests in a given timeframe.

0.3.3(12y ago)1249.7k↓35.4%2DBADPHPPHP &gt;=5.3.0

Since Aug 8Pushed 12y ago2 watchersCompare

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

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

Throttle (v0.3.3)
=================

[](#throttle-v033)

Ban identifier after certain amount of requests in a given timeframe.

[![Build Status](https://camo.githubusercontent.com/61e0fd8c8ca6d1c99496d9e0f28b405a8f09a979fcb59ad4c394d5aa82e44f67/68747470733a2f2f6170692e7472617669732d63692e6f72672f776562736f667477617265732f5468726f74746c652e706e67)](https://travis-ci.org/websoftwares/Throttle)

Installing via Composer (recommended)
-------------------------------------

[](#installing-via-composer-recommended)

Install composer in your project:

```
curl -s http://getcomposer.org/installer | php

```

Create a composer.json file in your project root:

```
{
    "require": {
        "websoftwares/throttle": "dev-master"
    }
}

```

Install via composer

```
php composer.phar install

```

Usage
-----

[](#usage)

Basic usage of the `Throttle` class to ban an identifier.

```
use Websoftwares\Throttle, Websoftwares\Storage\Memcached, Monolog\Logger;

// Ip
$identifier = '$_SERVER["REMOTE_ADDR"]';
// Instantiate class
$throttle = new Throttle(new Logger('throttle'), new Memcached());

if($throttle->validate($identifier)) {
	// Success proceed
} else {
	// Banned
}
```

Logger
------

[](#logger)

Any logger library that implements the [PSR-3](https://github.com/php-fig/log) *LoggerInterface* should work, just create your Logger object and inject it into the `Throttle` constructor. For example the excellent logging library [Monolog](https://github.com/Seldaek/monolog).

Storage
-------

[](#storage)

Included is a `Memcached` example however it is very easy to use some other storage system just implement the *StorageInterface* and inject that object into the `Throttle` constructor.

\####*Caution*\#### Whatever storage system u decide to use, don not store the failed request data into your database, this could lead to a DDOS attack and take your database down.

Options
-------

[](#options)

U can override the default options by instantiating a `Throttle` class and pass in an *array* as the third argument.

```
$options = array(
	'banned' => 10, // Ban identifier after 10 attempts. (default 5)
	'logged' => 20, // Log identifier after 20 attempts. (default 10)
	'timespan' => 60 // The timespan for the duration of the ban. (default 86400)
	);

// Instantiate class
$throttle = new Throttle(new Logger('throttle'), new Memcached(), $options);
```

reset();
--------

[](#reset)

This will remove the identifier from the storage.

```
$throttle->reset($identifier);
```

remaining();
------------

[](#remaining)

This will return an integer that is the remaining attempt(s) available before identifier gets banned.

```
$throttle->remaining($identifier);
```

Memcached
---------

[](#memcached)

This requires u have the PHP memcached extension installed.

on Debian/Ubuntu systems for example install like this (requires administrative password).

```
sudo apt-get install php5-memcached

```

Testing
-------

[](#testing)

In the tests folder u can find several tests.

License
-------

[](#license)

[DBAD](http://www.dbad-license.org/ "DBAD") Public License.

Acknowledgement
---------------

[](#acknowledgement)

Converted from python example and comments from [Forrst.com](https://forrst.com/posts/Limiting_number_of_requests_in_a_given_timeframe-0BW "Forrst") post.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity52

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

Total

6

Last Release

4659d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

securityIPloginlimitRatethrottlebrute forceHammer

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[maba/gentle-force-bundle

Symfony bundle that integrates gentle-force library for limiting both brute-force attempts and ordinary requests, using leaky/token bucket algorithm, based on Redis

53517.6k1](/packages/maba-gentle-force-bundle)[maba/gentle-force

Library for limiting both brute-force attempts and ordinary requests, using leaky/token bucket algorithm, based on Redis

45591.0k2](/packages/maba-gentle-force)[codeconsortium/ccdn-user-security-bundle

CCDN User Security Bundle

60100.7k](/packages/codeconsortium-ccdn-user-security-bundle)[anyx/login-gate-bundle

Checking brute force attacks on site

59339.5k](/packages/anyx-login-gate-bundle)

PHPackages © 2026

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