Skip to content

dcabrejas/magento-rate-limit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

magento-rate-limit

Magento 2 adapter for the touhonoob/RateLimit Library

Installation

composer require dcabrejas/magento-rate-limit

Usage

//Inject the adapter via dependency injection
public function __construct(\Dcabrejas\RateLimit\Adapter\Magento $magentoAdapter)
{
  $this->magentoAdapter = $magentoAdapter;
}


$rateLimit = new \Touhonoob\RateLimit\RateLimit("myratelimit", 100, 3600, $this->magentoAdapter); // 100 Requests / Hour

$id = $_SERVER['REMOTE_ADDR']; // Use client IP as identity
if ($rateLimit->check($id) > 0) {
  echo "passed";
} else {
  echo "rate limit exceeded";
}

About

Rate Limit Adapter for Magento

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages