PHPackages                             thomasjohnkane/laravel-snooze - 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. thomasjohnkane/laravel-snooze

Abandoned → [https://github.com/thomasjohnkane/snooze](/?search=https%3A%2F%2Fgithub.com%2Fthomasjohnkane%2Fsnooze)Library

thomasjohnkane/laravel-snooze
=============================

Schedule future notifications and reminders in Laravel

2.9.0(3mo ago)90597897[9 issues](https://github.com/thomasjohnkane/snooze/issues)[7 PRs](https://github.com/thomasjohnkane/snooze/pulls)MITPHPPHP ^8.2CI passing

Since Oct 16Pushed 3mo ago12 watchersCompare

[ Source](https://github.com/thomasjohnkane/snooze)[ Packagist](https://packagist.org/packages/thomasjohnkane/laravel-snooze)[ RSS](/packages/thomasjohnkane-laravel-snooze/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (4)Versions (29)Used By (0)

Laravel Snooze
==============

[](#laravel-snooze)

> Schedule future notifications and reminders in Laravel

 [![](./snooze-logo-v1.png)](./snooze-logo-v1.png)

[![Build Status](https://camo.githubusercontent.com/95226cac2c046e992ecb5d7b3f73adde1fbaa64ddeb9ae7cf44ae5cef94063d4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f74686f6d61736a6f686e6b616e652f736e6f6f7a652f7068702e796d6c3f6272616e63683d6d6173746572)](https://github.com/thomasjohnkane/snooze/actions)[![styleci](https://camo.githubusercontent.com/cd33d8e797eff5c400adbbb41d9a14f8a3038fa6066264a3c69fe50fb2cb77f7/68747470733a2f2f7374796c6563692e696f2f7265706f732f3137333234363332392f736869656c64)](https://styleci.io/repos/173246329)

[![Latest Stable Version](https://camo.githubusercontent.com/797e811d1c00db6c31bfa52c0751a34e0b3747e87662d2f91171b630b799cb19/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61736a6f686e6b616e652f736e6f6f7a652f762f737461626c65)](https://packagist.org/packages/thomasjohnkane/snooze)[![Total Downloads](https://camo.githubusercontent.com/629512c2755774c473551dcdf285b433556e65bfdef450c84688e51e5a14250f/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61736a6f686e6b616e652f736e6f6f7a652f646f776e6c6f616473)](https://packagist.org/packages/thomasjohnkane/snooze)[![License](https://camo.githubusercontent.com/4505e40346e01fbacc6499e0db69fc0791bd8690b67a2d38a6f60f42d5b6cfef/68747470733a2f2f706f7365722e707567782e6f72672f74686f6d61736a6f686e6b616e652f736e6f6f7a652f6c6963656e7365)](https://packagist.org/packages/thomasjohnkane/snooze)

### Why use this package?

[](#why-use-this-package)

- Ever wanted to schedule a **future** notification to go out at a specific time? (was the delayed queue option not enough?)
- Want a simple on-boarding email drip?
- How about happy birthday emails?

#### Common use cases

[](#common-use-cases)

- Reminder system (1 week before appt, 1 day before, 1 hour before, etc)
- Follow-up surveys (2 days after purchase)
- On-boarding Email Drips (Welcome email after sign-up, additional tips after 3 days, upsell offer after 7 days)
- Short-Term Recurring reports (send every week for the next 4 weeks)

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

[](#installation)

Install via composer

```
composer require thomasjohnkane/snooze
```

```
php artisan migrate
```

### Publish Configuration File

[](#publish-configuration-file)

```
php artisan vendor:publish --provider="Thomasjohnkane\Snooze\ServiceProvider" --tag="config"
```

Usage
-----

[](#usage)

#### Using the model trait

[](#using-the-model-trait)

Snooze provides a trait for your model, similar to the standard `Notifiable` trait. It adds a `notifyAt()` method to your model to schedule notifications.

```
use Thomasjohnkane\Snooze\Traits\SnoozeNotifiable;
use Illuminate\Notifications\Notifiable;

class User extends Model {
    use Notifiable, SnoozeNotifiable;

    // ...
}

// Schedule a birthday notification
$user->notifyAt(new BirthdayNotification, Carbon::parse($user->birthday));

// Schedule for a week from now
$user->notifyAt(new NextWeekNotification, Carbon::now()->addDays(7));

// Schedule for new years eve
$user->notifyAt(new NewYearNotification, Carbon::parse('last day of this year'));
```

#### Using the ScheduledNotification::create helper

[](#using-the-schedulednotificationcreate-helper)

You can also use the `create` method on the `ScheduledNotification`.

```
ScheduledNotification::create(
     Auth::user(), // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addHour() // Send At
);
```

This is also useful for scheduling anonymous notifications (routed direct, rather than on a model).

```
$target = (new AnonymousNotifiable)
    ->route('mail', 'hello@example.com')
    ->route('sms', '56546456566');

ScheduledNotification::create(
     $target, // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addDay() // Send At
);
```

#### An important note about scheduling the `snooze:send` command

[](#an-important-note-about-scheduling-the-snoozesend-command)

Creating a scheduled notification will add the notification to the database. It will be sent by running `snooze:send` command at (or after) the stored `sendAt` time.

The `snooze:send` command is scheduled to run every minute by default. You can change this value (`sendFrequency`) in the published config file. Available options are `everyMinute`, `everyFiveMinutes`, `everyTenMinutes`, `everyFifteenMinutes`, `everyThirtyMinutes`, `hourly`, and `daily`.

The only thing you need to do is make sure `schedule:run` is also running. You can test this by running `php artisan schedule:run` in the console. [To make it run automatically, read here](https://laravel.com/docs/5.7/scheduling#introduction "Configure Laravel Scheduler").

> Note: If you would prefer snooze to not automatically schedule the commands, you can set the `scheduleCommands` config value to `false`

### Setting the send tolerance

[](#setting-the-send-tolerance)

If your scheduler stops working, a backlog of scheduled notifications will build up. To prevent users receiving all of the old scheduled notifications at once, the command will only send mail within the configured tolerance. By default this is set to 24 hours, so only mail scheduled to be sent within that window will be sent. This can be configured (in seconds) using the `SCHEDULED_NOTIFICATION_SEND_TOLERANCE` environment variable or in the `snooze.php` config file.

### Setting the prune age

[](#setting-the-prune-age)

The package can prune sent and cancelled messages that were sent/cancelled more than x days ago. You can configure this using the `SCHEDULED_NOTIFICATION_PRUNE_AGE` environment variable or in the `snooze.php` config file (unit is days). This feature is turned off by default.

#### Detailed Examples

[](#detailed-examples)

- [Delayed Notification (1 week)](./docs/examples/basic-delayed-notification.md "Delayed 1 Week Example")
- [Simple On-boarding Email Drip](./docs/examples/on-boarding-email-drip.md "On-boarding Drip Example")
- [Exposing Custom Data to the Notification/Email](./docs/examples/custom-data-example.md "Custom Data Example")

**Cancelling Scheduled Notifications**

```
$notification->cancel();
```

**Note:** you cannot cancel a notification that has already been sent.

**Rescheduling Scheduled Notifications**

```
$rescheduleAt = Carbon::now()->addDay(1)

$notification->reschedule($rescheduleAt)
```

**Note:** you cannot reschedule a notification that has already been sent or cancelled. If you want to duplicate a notification that has already been sent or cancelled, pass a truthy second parameter along with the new send date; `reschedule($date, true)`, or use the `scheduleAgainAt($date)` method shown below.

**Duplicate a Scheduled Notification to be sent again**

```
$notification->scheduleAgainAt($newDate); // Returns the new (duplicated) $notification
```

**Check a scheduled notification's status**

```
// Check if a notification is already cancelled

$result = $notification->isCancelled(); // returns a bool

// Check if a notification is already sent

$result = $notification->isSent(); // returns a bool
```

**Conditionally interrupt a scheduled notification**

If you'd like to stop an email from being sent conditionally, you can add the `shouldInterrupt()` method to any notification. This method will be checked immediately before the notification is sent.

For example, you might not send a future drip notification if a user has become inactive, or the order the notification was for has been canceled.

```
public function shouldInterrupt($notifiable) {
    return $notifiable->isInactive() || $this->order->isCanceled();
}
```

If this method is not present on your notification, the notification will *not* be interrupted. Consider creating a shouldInterupt trait if you'd like to repeat conditional logic on groups of notifications.

**Scheduled Notification Meta Information**

It's possible to store meta information on a scheduled notification, and then query the scheduled notifications by this meta information at a later stage.

This functionality could be useful for when you store notifications for a future date, but some change in the system requires you to update them. By using the meta column, it's possible to more easily query these scheduled notifications from the database by something else than the notifiable.

***Storing Meta Information***

Using the `ScheduledNotification::create` helper

```
ScheduledNotification::create(
     $target, // Target
     new ScheduledNotificationExample($order), // Notification
     Carbon::now()->addDay(), // Send At,
     ['foo' => 'bar'] // Meta Information
);
```

Using the `notifyAt` trait

```
  $user->notifyAt(new BirthdayNotification, Carbon::parse($user->birthday), ['foo' => 'bar']);
```

***Retrieving Meta Information from Scheduled Notifications***

You can call the `getMeta` function on an existing scheduled notification to retrieve the meta information for the specific notification.

Passing no parameters to this function will return the entire meta column in array form.

Passing a string key (`getMeta('foo')`), will retrieve the specific key from the meta column.

***Querying Scheduled Notifications using the ScheduledNotification::findByMeta helper***

It's possible to query the database for scheduled notifications with certain meta information, by using the `findByMeta` helper.

```
  ScheduledNotification::findByMeta('foo', 'bar'); //key and value
```

The first parameter is the meta key, and the second parameter is the value to look for.

> Note: The index column doesn't currently make use of a database index

**Conditionally turn off scheduler**

If you would like to disable sending of scheduled notifications, set an env variable of `SCHEDULED_NOTIFICATIONS_DISABLED` to `true`. You will still be able to schedule notifications, and they will be sent once the scheduler is enabled.

This could be useful for ensuring that scheduled notifications are only sent by a specific server, for example.

**Enable onOneServer**

If you would like the `snooze` commands to utilise the Laravel Scheduler's `onOneServer` functionality, you can use the following environment variable:

```
SCHEDULED_NOTIFICATIONS_ONE_SERVER = true
```

Running the Tests
-----------------

[](#running-the-tests)

```
composer test
```

Security
--------

[](#security)

If you discover any security related issues, please email instead of using the issue tracker.

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

[](#contributing)

1. Fork it ()
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request

Credits
-------

[](#credits)

- [Thomas Kane &amp;&amp; Flux Bucket](https://github.com/thomasjohnkane)
- [Atymic](https://github.com/atymic)
- [All contributors](https://github.com/thomasjohnkane/snooze/graphs/contributors)

This package is bootstrapped with the help of [melihovv/laravel-package-generator](https://github.com/melihovv/laravel-package-generator).

###  Health Score

60

—

FairBetter than 99% of packages

Maintenance79

Regular maintenance activity

Popularity39

Limited adoption so far

Community28

Small or concentrated contributor base

Maturity80

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~155 days

Total

22

Last Release

111d ago

Major Versions

1.0.8 → 2.0.02021-09-13

PHP version history (6 changes)v1.0.0PHP &gt;=7.2

1.0.3PHP &gt;=7.2.5

2.2.0PHP &gt;=7.4

2.3.0PHP ^8.0 | ^8.1

2.5.0PHP ^8.1

2.8.0PHP ^8.2

### Community

Maintainers

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

---

Top Contributors

[![thomasjohnkane](https://avatars.githubusercontent.com/u/8945177?v=4)](https://github.com/thomasjohnkane "thomasjohnkane (50 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (36 commits)")[![ricuss](https://avatars.githubusercontent.com/u/17425015?v=4)](https://github.com/ricuss "ricuss (3 commits)")[![cristiancalara](https://avatars.githubusercontent.com/u/6623183?v=4)](https://github.com/cristiancalara "cristiancalara (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![ettiennelouw](https://avatars.githubusercontent.com/u/1754421?v=4)](https://github.com/ettiennelouw "ettiennelouw (1 commits)")[![f-E-T](https://avatars.githubusercontent.com/u/87535893?v=4)](https://github.com/f-E-T "f-E-T (1 commits)")[![gborcherds](https://avatars.githubusercontent.com/u/7691166?v=4)](https://github.com/gborcherds "gborcherds (1 commits)")[![gpanos](https://avatars.githubusercontent.com/u/12728267?v=4)](https://github.com/gpanos "gpanos (1 commits)")[![joe-pritchard](https://avatars.githubusercontent.com/u/25373032?v=4)](https://github.com/joe-pritchard "joe-pritchard (1 commits)")[![pxlrbt](https://avatars.githubusercontent.com/u/22632550?v=4)](https://github.com/pxlrbt "pxlrbt (1 commits)")[![sakcaysoftware](https://avatars.githubusercontent.com/u/137806079?v=4)](https://github.com/sakcaysoftware "sakcaysoftware (1 commits)")[![Solomon04](https://avatars.githubusercontent.com/u/35110194?v=4)](https://github.com/Solomon04 "Solomon04 (1 commits)")[![thdebay](https://avatars.githubusercontent.com/u/1422621?v=4)](https://github.com/thdebay "thdebay (1 commits)")[![colq2](https://avatars.githubusercontent.com/u/25695283?v=4)](https://github.com/colq2 "colq2 (1 commits)")[![azarzag](https://avatars.githubusercontent.com/u/3733255?v=4)](https://github.com/azarzag "azarzag (1 commits)")[![danielsimkus](https://avatars.githubusercontent.com/u/8949315?v=4)](https://github.com/danielsimkus "danielsimkus (1 commits)")[![elishaukpong](https://avatars.githubusercontent.com/u/31503827?v=4)](https://github.com/elishaukpong "elishaukpong (1 commits)")

---

Tags

boarding-email-dripsdelayed-notificationsdelayed-queuedrip-campaignsemail-marketinglaravellaravel-frameworklaravel-packagenotificationsonboarding-emailsreminderreminder-emailsremindersscheduled-notificationssnoozenotificationsscheduledsnoozedelayed notifications

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thomasjohnkane-laravel-snooze/health.svg)

```
[![Health](https://phpackages.com/badges/thomasjohnkane-laravel-snooze/health.svg)](https://phpackages.com/packages/thomasjohnkane-laravel-snooze)
```

###  Alternatives

[thomasjohnkane/snooze

Schedule future notifications and reminders in Laravel

9071.5M2](/packages/thomasjohnkane-snooze)[laravel/slack-notification-channel

Slack Notification Channel for laravel.

89167.8M84](/packages/laravel-slack-notification-channel)[pragmarx/health

Laravel Server &amp; App Health Monitor and Notifier

2.0k1.0M2](/packages/pragmarx-health)[laravel/vonage-notification-channel

Vonage Notification Channel for laravel.

7562.8M12](/packages/laravel-vonage-notification-channel)[edvinaskrucas/notification

Package for Laravel for helping to manage flash / instant notifications / messages.

533392.5k9](/packages/edvinaskrucas-notification)[laravel-notification-channels/pusher-push-notifications

Pusher native Push Notifications driver.

281712.9k1](/packages/laravel-notification-channels-pusher-push-notifications)

PHPackages © 2026

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