PHP code example of suhayb / ratelimit

1. Go to this page and download the library: Download suhayb/ratelimit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

suhayb / ratelimit example snippets





uhayb\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
});