suhayb / ratelimit
a PHP Package to rate limit an identifier from running code
Installs: 11
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
pkg:composer/suhayb/ratelimit
Requires
- predis/predis: ^1.1
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2025-09-29 02:20:47 UTC
README
General purpose rate limiting for IP Address or any data
Installation
Use the package manager composer to install RateLimit.
composer require suhayb/ratelimit
Usage
<?php include_once 'vendor/autoload.php'; use \Suhayb\RateLimit\RateLimit; use \Suhayb\RateLimit\Adapters\ArrayAdapter; # could be change to any data source compatible with RateLimitQuery interface $dataSource = new ArrayAdapter([]); $rateLimit = new RateLimit(5, $dataSource); # threw Max Limit Exception on exceeding the limit $rateLimit->run("10.11.13.1", function () { # do anything });
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.