Guardian is a powerful and flexible rate limiting and error handling library for PHP applications. It provides a robust system for managing API rate limits, preventing abuse, and handling errors gracefully. Guardian can be used in any PHP project and has built-in support for Laravel applications. Full documentation: guardian.midnite.uk
Install Guardian via Composer:
composer require midnite81/guardian
use Midnite81\Guardian\Factories\GuardianFactory;use Midnite81\Guardian\Store\FileStore;use Midnite81\Guardian\Rules\RateLimitRule; $guardian = GuardianFactory::create( 'my-api', new FileStore('/path/to/cache'), [RateLimitRule::allow(100)->perMinute()]); $result = $guardian->send(function() { // Your API logic here});
For detailed usage instructions, API reference, and advanced configuration options, please refer to the official Guardian documentation:
As of October 2024, Guardian has just been released and there is no roadmap as such for it as yet. Its use in the wild might bring in required features.
Some initial thoughts:
Contributions are welcome! Please see our Contributing Guide for more details.
Guardian is open-sourced software licensed under the MIT license.