Skip to content

alexandrzhulev/RequestLimitBundle

 
 

Repository files navigation

SensioLabsInsight Build Status Scrutinizer Code Quality Maintainability

RequestLimitBundle

This bundle is a simple solution to restrict user access to some controller for a specified timeline.

This could be used for different cases when you need to pre

  • prevent flood - pushing users of irrelevant data;
  • prevent user to visit page very often, etc.

Installation

  1. Require bundle with:
    composer require 
  1. Register bundle in AppKernel:
 public function registerBundles()
    {
        $bundles = [
            ... ,
            new NV\RequestLimitBundle\NVRequestLimitBundle()
        ];
    ...
    }
  1. Configure bundle according to provider you use:
  1. Specify restriction_time in seconds:
nv_request_limit:
    restriction_time: 5

Usage

In your controller action add following line to restrict user access by user id:

$this->get('nv.request_limit.request_restrictor')->restrictRequestByUserId($userId);

or following to restrict by user IP:

$this->get('nv.request_limit.request_restrictor')->restrictRequestByIp($userIp);

These will restrict user access to the action for 10 minutes.

TODO

  1. Write tests

About

The bundle which provides a light way to restrict user access to some action for a specific time frame

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 67.4%
  • PHP 32.6%