承接 maatify/rate-limiter 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

maatify/rate-limiter

Composer 安装命令:

composer require maatify/rate-limiter

包简介

Flexible PSR-15 rate limiter supporting Redis, MongoDB, and MySQL via real and fake drivers. Provides multi-strategy algorithms, burst control, sliding window, token bucket, and integration with Maatify Data Repository.

README 文档

README

PSR-compliant distributed rate limiting engine supporting Redis, MongoDB, and MySQL with adaptive exponential backoff.

Maatify.dev

Version PHP PHP Version

Build

Monthly Downloads Total Downloads

Stars License Status Code Quality

PHPStan Coverage

Changelog Security

🚀 Overview

Maatify Rate Limiter is a fully decoupled, PSR-compliant rate-limiting engine designed for:

  • Native PHP
  • Slim Framework
  • Laravel Middleware
  • Custom API Gateways

It provides distributed rate-limiting with adaptive exponential backoff, unified across:

  • Redis
  • MongoDB
  • MySQL

Why this library?

  • Zero storage lock-in
  • Unified attempt/status/reset API
  • Global per-IP rate limit
  • Adaptive Exponential Backoff (2ⁿ)
  • Full PSR-7 / PSR-15 middleware compatibility
  • PHPStan Level Max ready

✅ Supported Drivers

Backend Driver Type Use Case
Redis Real Driver High-performance in-memory limits
MongoDB Real Driver Distributed analytics
MySQL Real Driver Persistent audit & compliance

📦 Installation

composer require maatify/rate-limiter

⚡ Quick Usage

use Maatify\RateLimiter\Resolver\RateLimiterResolver;
use Maatify\RateLimiter\Enums\RateLimitActionEnum;
use Maatify\RateLimiter\Enums\PlatformEnum;

$resolver = new RateLimiterResolver(['driver' => 'redis']);
$limiter  = $resolver->resolve();

$status = $limiter->attempt(
    '127.0.0.1',
    RateLimitActionEnum::LOGIN,
    PlatformEnum::WEB
);

echo $status->remaining;

📘 Full usage examples (Native, Slim, Laravel, API, Enums, Backoff): ➡️ examples/Examples.md

🧩 Key Features

  • Unified API: attempt(), status(), reset()
  • Global Per-IP Limit
  • Adaptive Exponential Backoff
  • DTO-based Response Model
  • PSR-7 / PSR-15 Middleware Ready
  • Custom Enum Contracts
  • Driver Resolver
  • Strict Validation & Type Safety
  • PHPStan Level Max

📄 Documentation

📚 Development History & Phase Details
  • Phase 1 – Environment Setup
  • Phase 2 – Core Architecture
  • Phase 3 – Storage Drivers
  • Phase 3.1 – Enum Contracts Refactor
  • Phase 4 – Resolver & Middleware
  • Phase 4.1 – Continuous Integration
  • Phase 5 – Exponential Backoff & Global Rate Limit

🧱 Dependencies Overview

maatify/rate-limiter relies on PSR standards and selected open-source libraries.

🔌 Direct Open-Source Dependencies

Library Purpose
psr/http-message HTTP message interfaces
psr/http-server-middleware PSR-15 middleware
psr/http-server-handler Request handler
redis / predis Redis driver
mongodb/mongodb MongoDB driver
phpunit/phpunit Testing
phpstan/phpstan Static analysis

🧪 Testing

composer test

Runs:

  • Driver consistency tests
  • Resolver tests
  • Middleware header tests
  • Backoff & global limit tests
  • Coverage reporting

🪪 License

MIT License © Maatify.dev — Free to use, modify, and distribute with attribution.

👤 Author

Engineered by Mohamed Abdulalim (@megyptm)
Backend Lead & Technical Architect — https://www.maatify.dev

🤝 Contributors

Special thanks to the Maatify.dev engineering team and all open-source contributors. Your efforts help make this library stable, secure, and production-ready.

Before opening a Pull Request, please read:

Built with ❤️ by Maatify.dev — Unified Ecosystem for Modern PHP Libraries

maatify/rate-limiter 适用场景与选型建议

maatify/rate-limiter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 163 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 11 月 07 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「redis」 「mysql」 「mongo」 「throttle」 「pdo」 「middleware」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 maatify/rate-limiter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 maatify/rate-limiter 我们能提供哪些服务?
定制开发 / 二次开发

基于 maatify/rate-limiter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 163
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 35
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-07