Rate limitation across the board in Yii2?

I am looking for an easy way to implement rate limitation into my Yii2 app. I have already done so for the REST API and it works quite well. However, I would like to add rate limitation to my main app which includes guests, i.e. non-authenticated users, for which the IP address would be used to identify them.

What solution would you recommend? How can I add rate limitation to every action of every controller? I guess I will have to implement it into a new controller and derive all the others from this one.

Thank you for your help!


There’s nothing built-in for that. I guess the best way would be to copy and adjust RateLimiter into GuestRateLimiter.