vectorifyai/guzzle-rate-limiter
Composer 安装命令:
composer require vectorifyai/guzzle-rate-limiter
包简介
Guzzle middleware for preventive rate limiting with multi-store support, progressive delays, and cross-process coordination.
README 文档
README
A sophisticated Guzzle middleware for preventive rate limiting with multi-store support, progressive delays, and cross-process coordination. It works in accordance with the IETF standard by using the X-RateLimit-Remaining (number of requests remaining in the current rate limit window) and Retry-After (number of seconds to wait before retrying the request again) values available in the response headers.
Features
- Intelligent Rate Limiting: Progressive delays based on remaining API quota
- Multi-Store Support: InMemory, Laravel Cache, Symfony Cache, Filesystem, and more
- Cross-Process Coordination: Share rate limit state across multiple processes (i.e. queue jobs)
- Automatic Recovery: Handles 429 responses with exponential backoff
- Flexible Configuration: Customizable thresholds and delays
- PSR-3 Logging: Built-in logging with configurable levels
Installation
composer require vectorifyai/guzzle-rate-limiter
Quick Start
use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use Vectorify\GuzzleRateLimiter\RateLimiterMiddleware; use Vectorify\GuzzleRateLimiter\Stores\InMemoryStore; $stack = HandlerStack::create(); $stack->push(new RateLimiterMiddleware(new InMemoryStore)); $client = new Client([ 'handler' => $stack, ]);
Usage
Basic Usage
use Vectorify\GuzzleRateLimiter\RateLimiterMiddleware; use Vectorify\GuzzleRateLimiter\Stores\InMemoryStore; $middleware = new RateLimiterMiddleware(new InMemoryStore);
Laravel Integration
use Vectorify\GuzzleRateLimiter\Stores\LaravelStore; $store = new LaravelStore(cache(), 'api:rate_limit'); $middleware = new RateLimiterMiddleware($store);
Symfony Integration
use Vectorify\GuzzleRateLimiter\Stores\SymfonyStore; use Symfony\Component\Cache\Adapter\RedisAdapter; $cache = new RedisAdapter(/* redis client */); $store = new SymfonyStore($cache, 'api:rate_limit'); $middleware = new RateLimiterMiddleware($store);
Filesystem Integration
use Vectorify\GuzzleRateLimiter\Stores\FilesystemStore; use League\Flysystem\Local\LocalFilesystemAdapter; // Local filesystem $adapter = new LocalFilesystemAdapter('/path/to/cache'); $store = new FilesystemStore($adapter); $middleware = new RateLimiterMiddleware($store); // AWS S3 use League\Flysystem\AwsS3V3\AwsS3V3Adapter; $s3Adapter = new AwsS3V3Adapter($s3Client, $bucket, $prefix); $store = new FilesystemStore($s3Adapter); // SFTP use League\Flysystem\PhpseclibV3\SftpAdapter; $sftpAdapter = new SftpAdapter(/* SFTP connection settings */); $store = new FilesystemStore($sftpAdapter);
Advanced Configuration
$middleware = new RateLimiterMiddleware( store: new InMemoryStore, cachePrefix: 'my_api:rate_limit', logger: $customLogger, );
Changelog
Please see Releases for more information on what has changed recently.
Contributing
Pull requests are more than welcome. You must follow the PSR coding standards.
Security
Please review our security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see LICENSE for more information.
vectorifyai/guzzle-rate-limiter 适用场景与选型建议
vectorifyai/guzzle-rate-limiter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 5.72k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2025 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「symfony」 「php」 「api」 「cache」 「Guzzle」 「rate limiting」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vectorifyai/guzzle-rate-limiter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vectorifyai/guzzle-rate-limiter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vectorifyai/guzzle-rate-limiter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The bundle for easy using json-rpc api on your project
A PSR-7 compatible library for making CRUD API endpoints
Bundle Symfony DaplosBundle
Alfabank REST API integration
Biblioteca PHP pura para pagamentos SISP/Vinti4 de Cabo Verde.
Zero-dependency raw PHP DNS resolver, domain-ownership verification, and intoDNS/MxToolbox-style diagnostics. Queries authoritative nameservers directly over sockets — never trusts the recursive cache for ownership checks.
统计信息
- 总下载量: 5.72k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 26
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-08