PHPackages                             testmonitor/notify-floodgate - 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. [Mail &amp; Notifications](/categories/mail)
4. /
5. testmonitor/notify-floodgate

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

testmonitor/notify-floodgate
============================

A Laravel package to buffer notifications and prevent notification floods.

11PHP

Since Jun 10Pushed 1mo agoCompare

[ Source](https://github.com/testmonitor/notify-floodgate)[ Packagist](https://packagist.org/packages/testmonitor/notify-floodgate)[ RSS](/packages/testmonitor-notify-floodgate/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Notify Floodgate
================

[](#notify-floodgate)

[![Latest Stable Version](https://camo.githubusercontent.com/4ec324e99264338e89baa453e2944327c3e3293d5539a7059a5b89231118c7bb/68747470733a2f2f706f7365722e707567782e6f72672f746573746d6f6e69746f722f6e6f746966792d666c6f6f64676174652f762f737461626c65)](https://packagist.org/packages/testmonitor/notify-floodgate)[![CircleCI](https://camo.githubusercontent.com/f6dd7e3bae978d951c4fa247c1ed5af648d3025d6985ba46967e532da85503f7/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f6769746875622f746573746d6f6e69746f722f6e6f746966792d666c6f6f64676174652e737667)](https://circleci.com/gh/testmonitor/notify-floodgate)[![StyleCI](https://camo.githubusercontent.com/99019a6da148c7525114d2545d6b73853c1141dbe7859b1a2d8354ec6b4b73b0/68747470733a2f2f7374796c6563692e696f2f7265706f732f313230363938383934302f736869656c64)](https://styleci.io/repos/1206988940)[![License](https://camo.githubusercontent.com/9adc81f3c3ed75a0ff0c2797edad6ddff3384a0c699d4b6942c790a04486e264/68747470733a2f2f706f7365722e707567782e6f72672f746573746d6f6e69746f722f6e6f746966792d666c6f6f64676174652f6c6963656e7365)](https://packagist.org/packages/testmonitor/notify-floodgate)

A Laravel package that prevents notification floods by buffering queued notifications within a time window. When a single notification arrives, it is sent as-is. When multiple notifications of the same type arrive within the window, they are grouped into a single summary notification.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Preparing Your Notification](#preparing-your-notification)
    - [Sending a Summary](#sending-a-summary)
    - [Customizing the Buffer Window](#customizing-the-buffer-window)
    - [Customizing the Threshold](#customizing-the-threshold)
    - [Bypassing the Floodgate](#bypassing-the-floodgate)
    - [Customizing the Summary Notification](#customizing-the-summary-notification)
- [Tests](#tests)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

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

[](#installation)

This package can be installed through Composer:

```
composer require testmonitor/notify-floodgate
```

The package will register itself automatically via Laravel's package discovery.

Publish the configuration file:

```
php artisan vendor:publish --tag=floodgate-config
```

Configuration
-------------

[](#configuration)

The configuration file is located at `config/floodgate.php`:

```
return [

    /*
     * The number of seconds to wait before flushing a notification buffer.
     * During this window, additional notifications of the same type are
     * grouped and sent as a single summary.
     */
    'delay' => 10,

    /*
     * The notification class used to send a summary when multiple notifications
     * are buffered. Swap this for your own class to fully customize the output.
     */
    'summary' => \TestMonitor\Floodgate\Notifications\SummaryNotification::class,

    /*
     * Cache store and key prefix used to hold buffered notifications.
     * The store must support atomic locks (e.g. Redis, Memcached, database).
     */
    'cache' => [
        'store' => null,
        'prefix' => 'floodgate',
    ],

];
```

Usage
-----

[](#usage)

### Preparing Your Notification

[](#preparing-your-notification)

Add the `Gateable` trait and a `middleware` method to any queued notification you want to throttle:

```
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use TestMonitor\Floodgate\Concerns\Gateable;
use TestMonitor\Floodgate\Middleware\ThrottlesNotifications;

class IssueAssigned extends Notification implements ShouldQueue
{
    use Queueable, Gateable;

    public function middleware(): array
    {
        return [new ThrottlesNotifications];
    }

    // ...
}
```

That's all the setup required. The floodgate will now buffer notifications within the configured delay window and send a summary when the threshold is exceeded.

### Sending a Summary

[](#sending-a-summary)

Implement `toSummary` on your notification to define what the summary looks like. It receives all buffered notification instances and should return an array shaped like your `toArray` method:

```
public function toSummary(array $items): array
{
    return [
        'message' => ':count issues have been assigned to you',
        'url' => route('issues.index'),
        'icon' => 'exclamation-circle',
        'properties' => ['count' => count($items)],
    ];
}
```

When a summary is sent, the `toArray` method on each individual notification is passed to the summary mail view as `$items`, allowing you to include per-item detail alongside the grouped summary.

### Customizing the Buffer Window

[](#customizing-the-buffer-window)

Pass a custom delay in seconds to `ThrottlesNotifications` to override the configured default:

```
public function middleware(): array
{
    return [new ThrottlesNotifications(delay: 60)];
}
```

### Customizing the Threshold

[](#customizing-the-threshold)

By default, a summary is sent whenever more than one notification is buffered. Raise the threshold to allow a number of originals through before switching to a summary:

```
public function middleware(): array
{
    return [new ThrottlesNotifications(threshold: 3)];
}
```

With a threshold of `3`, up to three notifications are delivered individually. A fourth within the same window triggers a summary instead.

### Bypassing the Floodgate

[](#bypassing-the-floodgate)

Send a notification immediately, skipping the buffer entirely, by calling `withoutThrottling()`:

```
$user->notify((new IssueAssigned($issue))->withoutThrottling());
```

### Customizing the Summary Notification

[](#customizing-the-summary-notification)

The default `SummaryNotification` renders a mail view with `$summary` and `$items` variables. Publish the view to customise it:

```
php artisan vendor:publish --tag=floodgate-views
```

For full control, replace the summary class in the configuration:

```
'summary' => App\Notifications\IssueSummaryNotification::class,
```

Your custom class receives `$summary`, `$notifications`, and `$channels` in its constructor. Extend the default to override only what you need:

```
use TestMonitor\Floodgate\Notifications\SummaryNotification;

class IssueSummaryNotification extends SummaryNotification
{
    protected function subject(): string
    {
        return 'Your issue activity summary';
    }
}
```

Tests
-----

[](#tests)

The package contains a full test suite. Run it using:

```
composer test
```

Changelog
---------

[](#changelog)

Refer to [CHANGELOG](CHANGELOG.md) for more information.

Contributing
------------

[](#contributing)

Refer to [CONTRIBUTING](CONTRIBUTING.md) for contributing details.

Credits
-------

[](#credits)

- **Thijs Kok** - *Lead developer* - [ThijsKok](https://github.com/thijskok)
- **Stephan Grootveld** - *Developer* - [Stefanius](https://github.com/stefanius)
- **Frank Keulen** - *Developer* - [FrankIsGek](https://github.com/frankisgek)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

20

—

LowBetter than 12% of packages

Maintenance60

Regular maintenance activity

Popularity3

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 77.8% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/39f48c881813b7d3b044ca5660aa5ab9e60b5dd7c34ed4a47acbb11bd20b7593?d=identicon)[thijskok](/maintainers/thijskok)

---

Top Contributors

[![thijskok](https://avatars.githubusercontent.com/u/1344550?v=4)](https://github.com/thijskok "thijskok (7 commits)")[![stefanius](https://avatars.githubusercontent.com/u/2707905?v=4)](https://github.com/stefanius "stefanius (2 commits)")

### Embed Badge

![Health badge](/badges/testmonitor-notify-floodgate/health.svg)

```
[![Health](https://phpackages.com/badges/testmonitor-notify-floodgate/health.svg)](https://phpackages.com/packages/testmonitor-notify-floodgate)
```

PHPackages © 2026

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