PHPackages                             shippinno/notification - 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. shippinno/notification

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

shippinno/notification
======================

v3.0.0(2y ago)12.0k1[1 PRs](https://github.com/shippinno/notification/pulls)1PHPPHP ^8.2CI failing

Since Nov 5Pushed 2y ago5 watchersCompare

[ Source](https://github.com/shippinno/notification)[ Packagist](https://packagist.org/packages/shippinno/notification)[ RSS](/packages/shippinno-notification/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (14)Versions (42)Used By (1)

Notification
============

[](#notification)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/3a3cbc7e69854889fbce2bb5b06a9823ec23cda0bd8fe29e035f99bcb06f9890/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7368697070696e6e6f2f6e6f74696669636174696f6e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/shippinno/notification/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/547533a87022788b15602031cb3fd69302c2afa7709d73f9b7f4744b6b737660/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7368697070696e6e6f2f6e6f74696669636174696f6e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/shippinno/notification/?branch=master)[![Build Status](https://camo.githubusercontent.com/085e78b825b3632d4e992d7f3ae43741dc10fe176b31fe6cfc14b99374c1e20a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7368697070696e6e6f2f6e6f74696669636174696f6e2f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/shippinno/notification/build-status/master)

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

[](#installation)

```
$ composer require shippinno/notification
```

Basic Usage
-----------

[](#basic-usage)

### Create and send a notification

[](#create-and-send-a-notification)

Create a `Notification` with a `Destination` and send it through a `Gateway`.

```
use Shippinno\Email\SwiftMailer\SwiftMailerSendEmail;
use Shippinno\Notification\Domain\Model\Notification;
use Shippinno\Notification\Domain\Model\NotificationNotSentException;
use Shippinno\Notification\Infrastructure\Domain\Model\EmailGateway;

$notification = new Notification(
    new EmailDestination(
        [new EmailAddress('to@example.com')],
    ),
    new Subject('Hello'),
    new Body('This is a notification.'),

);

$gateway = new EmailGateway(
    new SwiftMailerSendEmail(...),
    new EmailAddress('from@example.com')
);

try {
    $gateway->send($notification);
} catch (NotificationNotSentException $e) {
    // ...
}
```

`Gateway` has to be compatible with the `Destination` (check `Destination::sendsToDestination(Destination $destination)`). In the case above, we assume `EmailGateway` accepts notifications with `EmailDestination`.

### Persist notifications

[](#persist-notifications)

Use `NotificationRepository` to persist notifications on your database.

If you use `DoctrineNotificationRepository` and set `$isPrecocious` attribute to `true`, you do not have to do `EntityManager::flush()`.

```
$repository = new DoctrineNotificationRepository($em, $class, true); // $isPrecocious === true
$repository->add($notification); // Already flushed.
```

You can retrieve fresh (not sent or failed) notifications to send them.

```
$notifications = $repository->freshNotifications();
```

Working with persisted notifications, you should want to mark them as sent or failed after trying to send.

If your `DoctrineNotificationRepository` is precocious, calling `persist()` will flush immediately.

```
try {
    $gateway->send($notification);
    $notification->markSent();
} catch (NotificationNotSentException $e) {
    $notification->markFailed($e->__toString()); // mark it failed with the reason
} finally {
    $repository->persist($notification);
}
```

Advanced usage
--------------

[](#advanced-usage)

### Using templates

[](#using-templates)

Let’s say you have [Liquid](https://shopify.github.io/liquid/) templates like:

```
$ tree -d /templates
/templates
|-- hello__subject.liquid
`-- hello__body.liquid
$
$ cat /templates/hello.subject.liquid
Hello, {{ you }} !!
$
$ cat /templates/hello.body.liquid
Good bye, {{ her }} :)
```

Then you can create notifications using those templates with `TemplateNotificationFactory`.

```
use League\Flysystem\Adapter\Local;
use League\Flysystem\Filesystem;
use Shippinno\Template\Liquid;
use Shippinno\Notification\Domain\Model\TemplateNotificationFactory;

$template = new Liquid(new Filesystem(new Local('/templates')));
$factory = new TemplateNotificationFactory($template);
$notification = $factory->create(
    'hello', // template name
    ['you' => 'Shippinno', 'her' => 'Jessica']), // variables for the template
    new EmailDestination([new EmailAddress('to@example.com')])
);
$notification->subject()->subject(); // => 'Hello Shippinno !!'
$notification->body()->body(); // => 'Good bye Jessica :)'
```

Check out [shippinno/template](https://github.com/shippinno/template-php) for more details how the template things work.

### Gateway routing

[](#gateway-routing)

`SendNotification` service routes a notification to and send it through a gateway designated on `GatewayRegistry`.

```
use Shippinno\Notification\Domain\Model\SendNotification;
use Shippinno\Notification\Domain\Model\GatewayRegistry;

$gatewayRegistry = new GatewayRegistry;
$gatewayRegistry->set('EmailDestination', new EmailGateway(...));
$gatewayRegistry->set('SlackChannelDestination', new SlackGateway(...));

$emailNotification = new Notification(new EmailDestination(...), ...);
$slackChannelNotification = new Notification(new SlackChannelDestination(...), ...);

$sendNotifiation = new SendNotification($gatewayRegistry);
$sendNotification->execute($emailNotification); // will send an email
$sendNotification->execute($slackChannelNotification); // will send a message to the Slack channel
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 Bus Factor1

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

###  Release Activity

Cadence

Every ~49 days

Recently: every ~308 days

Total

37

Last Release

988d ago

Major Versions

v0.2.4 → v1.0.02018-11-06

v1.4.4 → v2.0.02021-12-15

v2.1.0 → v3.0.02023-08-31

PHP version history (2 changes)v2.0.0PHP ^7.4

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c0c43c3f3e8303e9cbefffe9886a7f7b4f4f05f76c756f7b654c8d1d30d6d79?d=identicon)[tanigami](/maintainers/tanigami)

![](https://www.gravatar.com/avatar/398e46df56f8428891ac5447f9dccf4a12c1dc183e6988449ebb4d39d102ab68?d=identicon)[yfhub](/maintainers/yfhub)

![](https://www.gravatar.com/avatar/7bd9c65f9e0b7b11614b51b485bb50c545fccc58496ab2490b8d849aa90c950a?d=identicon)[HMuramatsu](/maintainers/HMuramatsu)

---

Top Contributors

[![tanigami](https://avatars.githubusercontent.com/u/86785?v=4)](https://github.com/tanigami "tanigami (54 commits)")[![kimurasayo](https://avatars.githubusercontent.com/u/76583053?v=4)](https://github.com/kimurasayo "kimurasayo (8 commits)")[![HMuramatsu](https://avatars.githubusercontent.com/u/28722773?v=4)](https://github.com/HMuramatsu "HMuramatsu (2 commits)")[![yfhub](https://avatars.githubusercontent.com/u/22097897?v=4)](https://github.com/yfhub "yfhub (2 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/shippinno-notification/health.svg)

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

###  Alternatives

[opensolutions/vimbadmin

ViMdAdmin :: Virtual Mailbox Administration

48613.5k](/packages/opensolutions-vimbadmin)[concrete5/core

Concrete core subtree split

19159.3k48](/packages/concrete5-core)[serendipity_hq/bundle-aws-ses-monitor

Symfony bundle to monitor AWS SES bounces, complaints and deliveries through SNS. Comes with a command to fully configure the topics and includes configurable SwiftMailer filter to avoid sending emails to bounced and complained emails.

1380.7k](/packages/serendipity-hq-bundle-aws-ses-monitor)[azine/mailgunwebhooks-bundle

Symfony2 Bundle to easily capture feedback from mailgun.com via their provided webhooks

104.1k](/packages/azine-mailgunwebhooks-bundle)

PHPackages © 2026

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