PHPackages                             andrey-helldar/spammers - 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. andrey-helldar/spammers

Abandoned → [johannebert/laravel-spam-protector](/?search=johannebert%2Flaravel-spam-protector)ArchivedLibrary[Security](/categories/security)

andrey-helldar/spammers
=======================

Simple package to prevent accessing of spammers to Laravel application

v1.2.1(5y ago)1373MITPHPPHP ^5.6|^7.0|^8.0

Since Dec 4Pushed 5y ago1 watchersCompare

[ Source](https://github.com/andrey-helldar/spammers)[ Packagist](https://packagist.org/packages/andrey-helldar/spammers)[ Fund](https://money.yandex.ru/to/410012115955701)[ Fund](https://paypal.me/helldar)[ RSS](/packages/andrey-helldar-spammers/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (8)Versions (15)Used By (0)

Spammers for Laravel 5.4+
=========================

[](#spammers-for-laravel-54)

Simple package to prevent accessing of spammers to Laravel application.

[![spammers](https://user-images.githubusercontent.com/10347617/40197731-f2c64fd2-5a1c-11e8-8a4e-4f047e1918d2.png)](https://user-images.githubusercontent.com/10347617/40197731-f2c64fd2-5a1c-11e8-8a4e-4f047e1918d2.png)

 [![StyleCI](https://camo.githubusercontent.com/13a9023ed230ca278678e9e08882d6491508c97715a9723489c9a008e65ffcf4/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131323936363331312f736869656c64)](https://styleci.io/repos/112966311) [![Total Downloads](https://camo.githubusercontent.com/2a7f7c0d65e0b86742ad5704691715f220e9c369a764a60c0ca16420c055eacb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616e647265792d68656c6c6461722f7370616d6d6572732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/andrey-helldar/spammers) [![Latest Stable Version](https://camo.githubusercontent.com/df9ccbf1dc6e932b167007f6536a325647f9dcc4acbf1520a5cf6f8d6d14fe15/68747470733a2f2f706f7365722e707567782e6f72672f616e647265792d68656c6c6461722f7370616d6d6572732f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/andrey-helldar/spammers) [![Latest Unstable Version](https://camo.githubusercontent.com/228c7e5b54bcc79095434e1d8c9d0979a16059f869d0048c9890a52fd18e54ce/68747470733a2f2f706f7365722e707567782e6f72672f616e647265792d68656c6c6461722f7370616d6d6572732f762f756e737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/andrey-helldar/spammers) [![License](https://camo.githubusercontent.com/1ec6a1160cbe88b4426dca0a904824c368adbefa209706e6297841a0958718fe/68747470733a2f2f706f7365722e707567782e6f72672f616e647265792d68656c6c6461722f7370616d6d6572732f6c6963656e73653f666f726d61743d666c61742d737175617265)](LICENSE)

Installation
------------

[](#installation)

To get the latest version of this package, simply require the project using [Composer](https://getcomposer.org/):

```
$ composer require andrey-helldar/spammers
```

Instead, you may of course manually update your require block and run `composer update` if you so choose:

```
{
    "require": {
        "andrey-helldar/spammers": "^1.0"
    }
}
```

If you don't use auto-discovery, add the ServiceProvider to the providers array in `config/app.php`:

```
Helldar\Spammers\ServiceProvider::class,

```

Next, call `php artisan vendor:publish` and `php artisan migrate` commands after set up [config/spammers.php](src/config/spammers.php) file and install the migrations by running `php artisan migrate` command.

Now, use `spammer()` helper and Artisan commands.

Documentation
-------------

[](#documentation)

- [Helpers Store](#helpers-store)
- [Helpers Accessing](#helpers-accessing)
- [Middleware](#middleware)
- [Console Command](#console-command)
- [Additional](#additional)
- [Simple Using](#simple-using)

### Helpers Store

[](#helpers-store)

Store IP-address in a spam-table:

```
spammer()
    ->ip('1.2.3.4')
    ->store();

// or

spammer('1.2.3.4')->store();

```

Delete IP-address from a spam-table:

```
spammer()
    ->ip('1.2.3.4')
    ->delete();

// or

spammer('1.2.3.4')->delete();

```

Restore IP-address from a spam-table:

```
spammer()
    ->ip('1.2.3.4')
    ->restore();

// or

spammer('1.2.3.4')->restore();

```

Check exists IP-address in a spam-table:

```
spammer()
    ->ip('1.2.3.4')
    ->exists();

// or

spammer('1.2.3.4')->exists();

```

### Helpers Accessing

[](#helpers-accessing)

To save an IP address with the URL in the database, use the helper `spammer()->access()`:

```
spammer()
    ->access()
    ->ip('1.2.3.4')
    ->url('/foo/bar')
    ->store();

// or

spammer('1.2.3.4')
    ->access()
    ->url('/foo/bar')
    ->store();

```

Ban when attempts to get pages with errors exceed a given number.

Example:

- When the number of attempts reaches `100` - ban for `24` hours.
- When the number of attempts reaches `300` - ban for `72` hours.
- When the number of attempts reaches `500` - `permanent ban`.

Default, `permanent ban`.

### Middleware

[](#middleware)

Next, add link to middleware in `$routeMiddleware` block in `app/Http/Kernel.php` file, and use him in `$middlewareGroups` blocks:

```
protected $middlewareGroups = [
    'web' => [
        // ...
        'spammers'
    ],

    'api' => [
        // ...
        'spammers'
    ],
];

protected $routeMiddleware = [
    // ...
    'spammers' => Helldar\Spammers\Middleware\Spammers::class
];
```

Or you can specify globally in the attribute `$middleware` of the `Http/Kernel.php` file:

```
protected $middleware = [
    // ...
    \Helldar\Spammers\Middleware\Spammers::class,
];
```

### Console Command

[](#console-command)

This package maybe called in a console:

```
spam:amnesty
spam:store 1.2.3.4
spam:delete 1.2.3.4
spam:restore 1.2.3.4
spam:exists 1.2.3.4

```

The `spam:amnesty` command allows you to delete IP-addresses that have expired.

### Additional

[](#additional)

You can use a `Helldar\Spammers\Models\Spammer` model. His extended `Illuminate\Database\Eloquent\Model`.

### Simple Using

[](#simple-using)

You can specify globally in the attribute `$middleware` of the `Http/Kernel.php` file:

```
protected $middleware = [
    // ...
    \Helldar\Spammers\Middleware\Spammers::class,
];
```

Next, in the `report()` method of file `app\Exceptions\Handler.php`, add the call to the `spammer()->access()` helper:

```
public function report(Exception $exception)
{
    spammer(request()->ip())
        ->access()
        ->url(request()->fullUrl())
        ->store();

    parent::report($exception);
}
```

And add a rule to the `schedule()` method of the `app/Console/Kernel.php` file:

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('spam:amnesty')
        ->everyThirtyMinutes();
}
```

Execute the commands:

```
php artisan vendor:publish
php artisan migrate
```

Customize the file `config/spammers.php` for your purposes.

Profit!

Copyright and License
---------------------

[](#copyright-and-license)

Laravel Spammers was written by Andrey Helldar for the Laravel framework 5.4 or later, and is released under the MIT License. See the [LICENSE](LICENSE) file for details.

Translation
-----------

[](#translation)

Translations of text and comment by Google Translate. Help with translation +1 in karma :)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity76

Established project with proven stability

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 ~86 days

Recently: every ~123 days

Total

14

Last Release

1958d ago

PHP version history (3 changes)1.0.0PHP &gt;=5.6.4

1.0.6PHP ^5.6|^7.0

v1.2.0PHP ^5.6|^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/b77790e612f1c9beed1e1533e36eba4954fbd6da2a5c9f71e845cd0f5465f0ad?d=identicon)[Helldar](/maintainers/Helldar)

---

Tags

laravelspammers

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/andrey-helldar-spammers/health.svg)

```
[![Health](https://phpackages.com/badges/andrey-helldar-spammers/health.svg)](https://phpackages.com/packages/andrey-helldar-spammers)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k43.5M5.2k](/packages/larastan-larastan)[laravel/passport

Laravel Passport provides OAuth2 server support to Laravel.

3.4k85.0M531](/packages/laravel-passport)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

759569.4k13](/packages/wendelladriel-laravel-validated-dto)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

71510.9M66](/packages/laravel-mcp)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)

PHPackages © 2026

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