PHPackages                             bentools/pusher - 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. bentools/pusher

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

bentools/pusher
===============

PHP Asynchronous Push Notification management

v0.4(9y ago)2571MITPHPPHP &gt;=7.1

Since Jan 31Pushed 1y ago1 watchersCompare

[ Source](https://github.com/bpolaszek/bentools-pusher)[ Packagist](https://packagist.org/packages/bentools/pusher)[ RSS](/packages/bentools-pusher/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (2)Versions (5)Used By (1)

PHP Webpush API implementation
==============================

[](#php-webpush-api-implementation)

Allows to send messages via WebPushAPI, on different providers (Google Chrome, Mozilla), asynchronously, on multiple recipients, using multiple API keys.

Important

This repository is no longer maintained and may be removed in a near future. You may consider creating a fork if you still require it.

Looks stable, but still experimental.

Pusher is inspired and based on the awesome [minishlink/web-push](https://github.com/web-push-libs/web-push-php) library, but with a different approach:

- Guzzle 6 has been prefered for sending messages, thanks to its asynchronous and parallel requests management
- A **Push** object is a bag that contains a **Message**, and **Recipients** associated to their **handlers**.
- A **Handler** is responsible for the correct delivery of a **Message** to a **Recipient** - currently implemented: GCM handler, Mozilla handler.
- Multiple **Handlers** can be used for a single **Push**, and a **Handler** may have several instances (i.e. when you use multiple GCM API keys)
- Every **Handler** must be able to return a *Promise* for handling a **Push**, to make things asynchronous and allow bulk processing
- The **Pusher** service is responsible to send a **Push** and change its state (*pending* =&gt; *done*).
- When the **Push** is done, it can tell which **Recipients** have not received the message and why (you may then unsubscribe them)

Several types of **Message** are implemented:

- A **Ping** message is a message without payload. Usually your service worker should fetch the payload at that moment (as it was in the earlier Webpush API implementations).
- A **Notification** message contains a json with all the info to display a Webpush notification (title, body, icon, ...)
- A **ServerMessage** contains a JSON which should be handled by your service worker to be sent to an active window instead of displaying a notification. This may help in changing remotely the DOM of an opened page.

Some example JS files are provided.

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

[](#installation)

`composer require bentools/pusher`

Example usage
-------------

[](#example-usage)

Consider the following *subscription* object:

```
{
  "endpoint": "https://updates.push.services.mozilla.com/wpush/v1/gAAAAABYmwfiuCps0P3TPZXSNc8aWol6_2Nqu0VVY6lpJ_xsIrtC8YyfPz_XnobR_Wh2PezdDZFonsfoezNsXykv4",
  "keys": {
    "auth": "5coZoiZAodiBZHCkWX5LoAbA",
    "p256dh": "BHI7P_CAsz3knooINFZZPFONPYTRTzEacYpOx4-hVigOuWjzkRWdkTZmmrAI3U11_z-lU"
  }
}
```

```
use BenTools\Pusher\Model\Message\Notification;
use BenTools\Pusher\Model\Push\Push;
use BenTools\Pusher\Model\Handler\MozillaHandler;
use BenTools\Pusher\Model\Recipient\Recipient;
use BenTools\Pusher\Pusher;
use GuzzleHttp\Client as GuzzleClient;

require_once __DIR__ . '/vendor/autoload.php';

$recipient = Recipient::unwrapJSON($json);
$guzzle    = new GuzzleClient();
$mozilla   = new MozillaHandler($guzzle);
$pusher    = new Pusher();
$push      = new Push();
$push->addRecipient($recipient, $mozilla);

$message   = new Notification(
    'Sounds interesting', // title
    'Seems to be working :)', // body
    'https://pbs.twimg.com/profile_images/555076551818354689/F26py9T__reasonably_small.png', // icon
    'https://github.com/bpolaszek/bentools-pusher', // link
    'hello world' // tag
);
$message->setTTL(60);

$push->setMessage($message);
$pusher->push($push);

if ($push->hasErrors()) {
    foreach ($push->getFailedRecipients() AS $recipient) {
        echo $push->getFailureReason($recipient);
        // Remove recipient from database or set it inactive
    }
}
```

TODO
----

[](#todo)

- Implement VAPID authentication
- Google FCM handler
- Tests
- Recipes

License
-------

[](#license)

MIT

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance30

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~3 days

Total

4

Last Release

3379d ago

### Community

Maintainers

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

---

Top Contributors

[![bpolaszek](https://avatars.githubusercontent.com/u/5569077?v=4)](https://github.com/bpolaszek "bpolaszek (8 commits)")

### Embed Badge

![Health badge](/badges/bentools-pusher/health.svg)

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

###  Alternatives

[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

1.1k3.4M35](/packages/laravel-notification-channels-telegram)[laravel-notification-channels/webpush

Web Push Notifications driver for Laravel.

7984.5M16](/packages/laravel-notification-channels-webpush)[s-ichikawa/laravel-sendgrid-driver

This library adds a 'sendgrid' mail driver to Laravel.

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[bentools/webpush-bundle

Send push notifications through Web Push Protocol to your Symfony users.

71274.3k](/packages/bentools-webpush-bundle)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1603.0M7](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2371.3M11](/packages/laravel-notification-channels-discord)

PHPackages © 2026

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