PHPackages                             vincendev/laraflood - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Security](/categories/security)
4. /
5. vincendev/laraflood

ActiveLibrary[Security](/categories/security)

vincendev/laraflood
===================

Flood protection for laravel 5

1.1.1(8y ago)01.2k1MITPHPPHP &gt;=5.6

Since Sep 18Pushed 8y ago2 watchersCompare

[ Source](https://github.com/VincenDev/laraflood)[ Packagist](https://packagist.org/packages/vincendev/laraflood)[ RSS](/packages/vincendev-laraflood/feed)WikiDiscussions 1.1.1 Synced 2w ago

READMEChangelog (1)Dependencies (1)Versions (6)Used By (0)

Laraflood - Antiflood system for Laravel using Cache
====================================================

[](#laraflood---antiflood-system-for-laravel-using-cache)

This tool designed for limiting some user requests.

This tool is based on: [ircop/Laraflood](https://github.com/ircop/antiflood), I have added / modified things that have been useful for my current project and I publish it in case it can be useful to someone!

INSTALL
-------

[](#install)

1: install via composer

```
composer require vincendev/laraflood

```

If you're using laravel 5.5: steps 2 and 3 are not necessary.

2: add service provider to `providers` array in `config/app.php`:

```
Vincendev\Laraflood\LarafloodServiceProvider::class,

```

3: add facade alias to `aliases` array in `config/app.php`:

```
'Laraflood' => Vincendev\Laraflood\FacadeLaraflood::class,

```

Usage
-----

[](#usage)

Checking for record existance with given identity and add attempt.

$identity - can be ip-address, user id, anything unique. Default is ip-address.

$action - What is the user trying to do? Submit-post, Login, Search, etc. Default is 'default'.

$maxAttempts - How many attempts do you want to give the user? Default is 5.

$minutes - Waiting time after attempts are over. Default is 5 minutes.

```
Laraflood::check( $identity = 'ip', $action = 'default', $maxAttempts = 5, $minutes = 5 );
Laraflood::check();
Laraflood::check( $user->id , 'submit-comment');
Laraflood::check( $user->id , 'report-comment', 1, 5);

/* Return bool */
```

Only check without add attempt.

```
Laraflood::checkOnly( $identity = 'ip', $action = 'default', $maxAttempts = 5, $minutes = 5 );
Laraflood::checkOnly();
Laraflood::checkOnly( $user->id , 'submit-comment');
Laraflood::checkOnly( $user->id , 'report-comment', 1, 5);

/* Return bool */
```

Add attempt for given $identity with ·$action on given $minutes. 'ip' by default is the real user ip.

```
Laraflood::addAttempt( $identity = 'ip', $action = 'default', $minutes = 5 );
Laraflood::addAttempt();
Laraflood::addAttempt('ip', 'like-post');
Laraflood::addAttempt( $user->id ,'default', 5 );

/* Void */
```

Get time left for given identity &amp; action.

```
Laraflood::timeLeft( $identity = 'ip', $action = 'default');
Laraflood::timeLeft();
Laraflood::timeLeft( 'ip', 'like-post');

/* Return string */
	# X hours
	# X minutes
	# X seconds

```

Returns array for given identity &amp; action

```
Laraflood::get($identity = 'ip', $action = 'default')
Laraflood::get();
Laraflood::get( 'ip', 'like-post');

/*
array:3 [▼
  "action" => "default"
  "attempts" => 1
  "expiration" => "2019-09-18 19:51:01.175237"
]
*/
```

Examples:
---------

[](#examples)

#### Limiting wrong login attempts for given IP address:

[](#limiting-wrong-login-attempts-for-given-ip-address)

This example limiting wrong login attempts from one ip-address to 5 tryes per 20 minutes:

```
public function postLogin()
{

/**
* If thes user ip has >= 5 failed login attempts in last 5 minutes, redirect user
* back with error:
*/

	if( Laraflood::check( 'ip' , 'login', 5, 5 ) === FALSE )
		return redirect()->back()->withErrors(["AntiFlood Protection! Try again in ".Laraflood::timeLeft('ip','login')." ."]);

	/**
	* Your code here..
	*/

}
```

#### Increment post views .

[](#increment-post-views-)

This code shows how increment post views only 1 view every 24 hours..

```
public function incrementPostViews()
{
		$action = "post-visit:" . $post->id; // Post unique ID
		$visitsPerUser = 1;
		$minutes = 1440; // 24Hours
        if(Laraflood::checkOnly('ip', $action, $visitsPerUser)){
			/**
			* Increment post views
			* Your code here..
			*/
			Laraflood::addAttempt('ip', $action, $minutes);
        }

}
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~60 days

Total

5

Last Release

2967d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9200574?v=4)[Vincent](/maintainers/VincenDev)[@VincenDev](https://github.com/VincenDev)

---

Top Contributors

[![VincenDev](https://avatars.githubusercontent.com/u/9200574?v=4)](https://github.com/VincenDev "VincenDev (3 commits)")[![fvalenciabg](https://avatars.githubusercontent.com/u/35342893?v=4)](https://github.com/fvalenciabg "fvalenciabg (2 commits)")

---

Tags

laravelsecurityspamantispamfloodantiflood

### Embed Badge

![Health badge](/badges/vincendev-laraflood/health.svg)

```
[![Health](https://phpackages.com/badges/vincendev-laraflood/health.svg)](https://phpackages.com/packages/vincendev-laraflood)
```

###  Alternatives

[akaunting/laravel-firewall

Web Application Firewall (WAF) package for Laravel

1.0k494.9k2](/packages/akaunting-laravel-firewall)[ircop/antiflood

Request flood protection for laravel

2025.0k1](/packages/ircop-antiflood)[enlightn/laravel-security-checker

A Laravel package to scan your dependencies for known security vulnerabilities.

51176.3k](/packages/enlightn-laravel-security-checker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
