PHPackages                             dnomyar/php-rate-limiter - 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. dnomyar/php-rate-limiter

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

dnomyar/php-rate-limiter
========================

Simple rate limiter

1.0.2(3y ago)08MITPHPPHP &gt;=7.2

Since Sep 1Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Dnomyar/php-rate-limiter)[ Packagist](https://packagist.org/packages/dnomyar/php-rate-limiter)[ RSS](/packages/dnomyar-php-rate-limiter/feed)WikiDiscussions main Synced 1mo ago

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

Low budget rate limiter
=======================

[](#low-budget-rate-limiter)

This is a low budget rate limiter. Low budget because it does not require any additional tool to work. It uses the file system as a repository. It can be used to protect a public form from bots or limit by user.

The current implementation allows to atomically update the bucket. If another request is trying to update the save bucket at the same it will throw an Exception.

Usage
-----

[](#usage)

This library provides a `RateLimiter` class that need to be initialized with a identificator corresponding to the resources that need to be limited. For instance:

- limit the number of submitions to a public page. In that case, the id could be `business-description`
- limit the number of call per user. In that case, the id could be `business-description-`

```
use Dnomyar\PhpFileSystemRateLimiter\Domain\RateLimiter;
use Dnomyar\PhpFileSystemRateLimiter\Domain\Model\Configuration\BucketSize;
use Dnomyar\PhpFileSystemRateLimiter\Domain\Model\Configuration\BucketTime;
use Dnomyar\PhpFileSystemRateLimiter\Domain\Model\Configuration\Duration;
use Dnomyar\PhpFileSystemRateLimiter\Infrastructure\Repository\LockFileImplementation;
use Dnomyar\PhpFileSystemRateLimiter\Infrastructure\Repository\BucketSerializerImplementation;
use Dnomyar\PhpFileSystemRateLimiter\Infrastructure\Repository\FileSystemFileAdapterImplementation;
use Dnomyar\PhpFileSystemRateLimiter\Infrastructure\Repository\FileSystemBucketRepository;

$rateLimiter = new RateLimiter(
     new BucketTime(Duration::seconds(10)),
     BucketSize::createBucketSize(6),
     new FileSystemBucketRepository(
        new FileSystemFileAdapterImplementation(),
        new BucketSerializerImplementation(),
        new LockFileImplementation()
     )
);

/*
 * return true of false if the call is allowed
 * thows a BucketRepositoryException if another request is trying to use the feature at the same time.
 */
$rateLimiter->allowCall('id-to-change');
```

Limitation
----------

[](#limitation)

If you are looking to use that for your project, use caution. This library was built to respect two important constraints: not using additionnal tool and a low level of parallel request for the same identificator.

Also, it would cause problems in case of a pick of load. It is advise to run load testing before using this library.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

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

Total

3

Last Release

1346d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21c40dea3a0f6815cd630604429dece01bd68454b34b83073ffd834d2e1ef015?d=identicon)[Dnomyar](/maintainers/Dnomyar)

---

Top Contributors

[![Dnomyar](https://avatars.githubusercontent.com/u/4415022?v=4)](https://github.com/Dnomyar "Dnomyar (12 commits)")

---

Tags

low-costphprate-limiterrate-limiting

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/dnomyar-php-rate-limiter/health.svg)

```
[![Health](https://phpackages.com/badges/dnomyar-php-rate-limiter/health.svg)](https://phpackages.com/packages/dnomyar-php-rate-limiter)
```

###  Alternatives

[vlucas/phpdotenv

Loads environment variables from `.env` to `getenv()`, `$\_ENV` and `$\_SERVER` automagically.

13.5k602.4M5.4k](/packages/vlucas-phpdotenv)[graham-campbell/result-type

An Implementation Of The Result Type

548378.1M7](/packages/graham-campbell-result-type)[phpcollection/phpcollection

General-Purpose Collection Library for PHP

1.0k64.0M34](/packages/phpcollection-phpcollection)[cypresslab/gitelephant

An abstraction layer for git written in PHP

6131.0M23](/packages/cypresslab-gitelephant)[friendsofsymfony/comment-bundle

This Bundle provides threaded comment functionality for Symfony applications

460751.2k5](/packages/friendsofsymfony-comment-bundle)[ps/fluent-traversable

Support for operating on collections and arrays by functional way. Inspired by guava's FluentIterable, java8 Stream framework and scala stuff

2929.4k1](/packages/ps-fluent-traversable)

PHPackages © 2026

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