PHP code example of tiendanube / throttler

1. Go to this page and download the library: Download tiendanube/throttler 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/ */

    

tiendanube / throttler example snippets




$storage = new TiendaNube\Throttler\Storage\InMemory();
$provider = new TiendaNube\Throttler\Provider\LeakyBucket();

$throttler = new \TiendaNube\Throttler\Throttler($provider,$storage);
if (!$throttler->throttle('client:1')) {
    // allow
} else {
    // deny
}