Skip to content

Latest commit

 

History

History
61 lines (47 loc) · 2.06 KB

README.md

File metadata and controls

61 lines (47 loc) · 2.06 KB

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