PHPackages                             fathkoc/rate-limiter-library - 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. fathkoc/rate-limiter-library

ActiveLibrary[API Development](/categories/api)

fathkoc/rate-limiter-library
============================

A simple PHP library for rate limiting API requests.

12PHP

Since Sep 27Pushed 1y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Rate Limiter Library
====================

[](#rate-limiter-library)

Introduction
------------

[](#introduction)

This is a simple PHP Rate Limiting library designed to limit API requests or user actions over a defined time window. It helps protect your application from abusive users or bots by controlling the rate of requests.

Features
--------

[](#features)

- Define a limit on the number of requests per a certain time window.
- Storage-agnostic, supports file storage, but can be extended to use Redis or other storage backends.
- Easy to integrate with any PHP application.

Usage
-----

[](#usage)

1. **Install the library**:

    If you're using composer, you can install it by running:

    ```

    ```

composer require fathkoc/rate-limiter-library

```

2. **Basic Example**:

```php
require_once __DIR__ . '/src/RateLimiter.php';
require_once __DIR__ . '/src/StorageInterface.php';
require_once __DIR__ . '/src/FileStorage.php';

use RateLimiterLibrary\RateLimiter;
use RateLimiterLibrary\FileStorage;

// Create storage folder if not exists
if (!is_dir(__DIR__ . '/storage')) {
    mkdir(__DIR__ . '/storage', 0777, true);
}

$storage = new FileStorage(__DIR__ . '/storage');
$rateLimiter = new RateLimiter(5, 60, $storage); // 5 requests in 60 seconds

$ipAddress = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1';

if ($rateLimiter->isAllowed($ipAddress)) {
    // Request is allowed
    echo "Request successful.";
} else {
    // Too many requests
    http_response_code(429); // Too Many Requests
    echo "Rate limit exceeded.";
}

```

3. **Extend Storage**:

    You can create your own storage class by implementing the `StorageInterface` and integrate Redis, Memcached, or any other storage system.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/fathkoc-rate-limiter-library/health.svg)

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M452](/packages/google-gax)

PHPackages © 2026

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