Yii2 Rate Limiting Api

前端 未结 5 1642
抹茶落季
抹茶落季 2021-01-14 20:30

I\'m worried about Yii2 Rate limiting api?

What is Rate limiting api, why this used?

Here are some methods from Yii2 Can a yii guru explain in simple words a

5条回答
  •  半阙折子戏
    2021-01-14 20:32

    you can use rate limithing composer.

    add :"ethercreative/yii2-ip-ratelimiter": "1.*"

    public function behaviors()
    {
        $behaviors = parent::behaviors();
        $behaviors['rateLimiter'] = [
            // Use class
            'class' => RateLimiter::className(),
    
            'rateLimit' => 1,
            'timePeriod' => 2,
    
            'separateRates' => false,
            'enableRateLimitHeaders' => false,
        ];
        return $behaviors;
    }
    

提交回复
热议问题