PHP code example of webhubworks / craft-rate-limiter

1. Go to this page and download the library: Download webhubworks/craft-rate-limiter 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/ */

    

webhubworks / craft-rate-limiter example snippets




use webhubworks\craftratelimiter\models\RateLimiterConfig;

return [
    '*' => [
    
        RateLimiterConfig::make()
            ->requestsPerSecond(1)
            ->requestsPerMinute(2)
            ->requestsPerHour(20)
            ->requestMethods(['POST', 'PUT', 'PATCH', 'DELETE'])
            ->addControllerAction(
                controllerClass: \craft\controllers\UsersController::class,
                controllerActions: ['login']
            ),
            
        RateLimiterConfig::make()
            ->requestsPerMinute(2)
            ->requestMethods(['POST', 'PUT', 'PATCH', 'DELETE'])
            ->anyActionOfController(\craft\controllers\SomeOtherController::class),
    ],
];