You may use RateLimiter by attaching it as a behavior to a controller or module, like the following,
php
public function behaviors()
{
return [
'rateLimiter' => [
'class' => \yii\filters\RateLimiter::className(),
],
];
}
When the user has exceeded his rate limit, RateLimiter will throw a [[TooManyRequestsHttpException]] exception.
Note that RateLimiter requires [[user]] to implement the RateLimitInterface. RateLimiter will
do nothing if [[user]] is not set or does not implement RateLimitInterface.