PHPackages                             ngoahamos/webpush - 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. ngoahamos/webpush

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

ngoahamos/webpush
=================

Web Push notification channel for Laravel

3.0.2(7y ago)169MITPHPPHP ^7.0

Since Aug 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/ngoahamos/webpush)[ Packagist](https://packagist.org/packages/ngoahamos/webpush)[ RSS](/packages/ngoahamos-webpush/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (6)Versions (11)Used By (0)

Web push notifications channel for Laravel
==========================================

[](#web-push-notifications-channel-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b3a35281da3cf73522d6fdbbe1141dcbe7e5abe132b11d47cc405fd639dcf68e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/webpush)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/d1ba1b540bee1d45ad3c0d2b2e4ff693cf1371ebb86e00c27743c94214b3e807/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/laravel-notification-channels/webpush)[![StyleCI](https://camo.githubusercontent.com/d386adc03c1229856431d41cbafaf9dcae52881de0ccd1a65bd0b1adfa6002e3/68747470733a2f2f7374796c6563692e696f2f7265706f732f36353534323230362f736869656c64)](https://styleci.io/repos/65542206)[![SensioLabsInsight](https://camo.githubusercontent.com/212b9413878549706ec4ce66b92bc6c2c85672bb6216a5ade679a6e3cfa3ac26/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f36616338623664352d633231352d346261352d396134372d6431623331326563313936642e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/6ac8b6d5-c215-4ba5-9a47-d1b312ec196d)[![Quality Score](https://camo.githubusercontent.com/394768e17dc714dea812f3fd93c62c902f17cc800a7e2fc2d259ccbf65d5e9d0/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/webpush)[![Code Coverage](https://camo.githubusercontent.com/26205e82560b125c792a21f85b8ba2020f7bdd9a5612270a6ed0b7b3878eec8d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-notification-channels/webpush/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/39795b96340b440eff9be2eb47b91aef67c23c529845e53ee95aa0d521f577f7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d6e6f74696669636174696f6e2d6368616e6e656c732f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-notification-channels/webpush)

This package makes it easy to send web push notifications with Laravel.

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

[](#installation)

You can install the package via composer:

```
composer require laravel-notification-channels/webpush
```

First you must install the service provider (skip for Laravel&gt;=5.5):

```
// config/app.php
'providers' => [
    ...
    NotificationChannels\WebPush\WebPushServiceProvider::class,
],
```

Add the `NotificationChannels\WebPush\HasPushSubscriptions` trait to your `User` model:

```
use NotificationChannels\WebPush\HasPushSubscriptions;

class User extends Model
{
    use HasPushSubscriptions;
}
```

Next publish the migration with:

```
php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="migrations"
```

Run the migrate command to create the necessary table:

```
php artisan migrate
```

You can also publish the config file with:

```
php artisan vendor:publish --provider="NotificationChannels\WebPush\WebPushServiceProvider" --tag="config"
```

Generate the VAPID keys (required for browser authentication) with:

```
php artisan webpush:vapid
```

This command will set `VAPID_PUBLIC_KEY` and `VAPID_PRIVATE_KEY`in your `.env` file.

**These keys must be safely stored and should not change.**

If you still want support [Google Cloud Messaging](https://console.cloud.google.com) set the `GCM_KEY` and `GCM_SENDER_ID` in your `.env` file.

Usage
-----

[](#usage)

Now you can use the channel in your `via()` method inside the notification as well as send a web push notification:

```
use Illuminate\Notifications\Notification;
use NotificationChannels\WebPush\WebPushMessage;
use NotificationChannels\WebPush\WebPushChannel;

class AccountApproved extends Notification
{
    public function via($notifiable)
    {
        return [WebPushChannel::class];
    }

    public function toWebPush($notifiable, $notification)
    {
        return (new WebPushMessage)
            ->title('Approved!')
            ->icon('/approved-icon.png')
            ->body('Your account was approved!')
            ->action('View account', 'view_account');
            // ->data(['id' => $notification->id])
            // ->badge()
            // ->dir()
            // ->image()
            // ->lang()
            // ->renotify()
            // ->requireInteraction()
            // ->tag()
            // ->vibrate()
    }
}
```

### Save/Update Subscriptions

[](#saveupdate-subscriptions)

To save or update a subscription use the `updatePushSubscription($endpoint, $key = null, $token = null)` method on your user:

```
$user = \App\User::find(1);

$user->updatePushSubscription($endpoint, $key, $token);
```

The `$key` and `$token` are optional and are used to encrypt your notifications. Only encrypted notifications can have a payload.

### Delete Subscriptions

[](#delete-subscriptions)

To delete a subscription use the `deletePushSubscription($endpoint)` method on your user:

```
$user = \App\User::find(1);

$user->deletePushSubscription($endpoint);
```

Demo
----

[](#demo)

For a complete implementation with a Service Worker check this [demo](https://github.com/cretueusebiu/laravel-web-push-demo).

Browser Compatibility
---------------------

[](#browser-compatibility)

See the [Push API](https://caniuse.com/#feat=push-api) browser compatibility.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Security
--------

[](#security)

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

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Cretu Eusebiu](https://github.com/cretueusebiu)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 56.7% 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 ~109 days

Recently: every ~162 days

Total

9

Last Release

2733d ago

Major Versions

0.2.0 → 1.0.02017-03-25

1.0.0 → 2.0.02017-10-23

2.0.0 → 3.0.02017-11-15

PHP version history (2 changes)0.0.1PHP &gt;=5.6.4

2.0.0PHP ^7.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16638567?v=4)[Amos Ngoah](/maintainers/ngoahamos)[@ngoahamos](https://github.com/ngoahamos)

---

Top Contributors

[![cretueusebiu](https://avatars.githubusercontent.com/u/1517945?v=4)](https://github.com/cretueusebiu "cretueusebiu (34 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (14 commits)")[![themsaid](https://avatars.githubusercontent.com/u/4332182?v=4)](https://github.com/themsaid "themsaid (2 commits)")[![JapSeyz](https://avatars.githubusercontent.com/u/2234034?v=4)](https://github.com/JapSeyz "JapSeyz (1 commits)")[![casperboone](https://avatars.githubusercontent.com/u/15815208?v=4)](https://github.com/casperboone "casperboone (1 commits)")[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (1 commits)")[![nmfzone](https://avatars.githubusercontent.com/u/10361906?v=4)](https://github.com/nmfzone "nmfzone (1 commits)")[![oyed](https://avatars.githubusercontent.com/u/172114265?v=4)](https://github.com/oyed "oyed (1 commits)")[![patrickpietens](https://avatars.githubusercontent.com/u/132625?v=4)](https://github.com/patrickpietens "patrickpietens (1 commits)")[![Pes8](https://avatars.githubusercontent.com/u/2906048?v=4)](https://github.com/Pes8 "Pes8 (1 commits)")[![JayBizzle](https://avatars.githubusercontent.com/u/340752?v=4)](https://github.com/JayBizzle "JayBizzle (1 commits)")[![codetheorist](https://avatars.githubusercontent.com/u/22813671?v=4)](https://github.com/codetheorist "codetheorist (1 commits)")[![ikoolik](https://avatars.githubusercontent.com/u/1555901?v=4)](https://github.com/ikoolik "ikoolik (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ngoahamos-webpush/health.svg)

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

###  Alternatives

[laravel-notification-channels/webpush

Web Push Notifications driver for Laravel.

8985.1M25](/packages/laravel-notification-channels-webpush)[spatie/laravel-health

Monitor the health of a Laravel application

87411.3M154](/packages/spatie-laravel-health)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2022.1M6](/packages/laravel-notification-channels-apn)[laravel-notification-channels/microsoft-teams

A Laravel Notification Channel for Microsoft Teams

1613.2M11](/packages/laravel-notification-channels-microsoft-teams)[laravel-notification-channels/discord

Laravel notification driver for Discord.

2381.4M13](/packages/laravel-notification-channels-discord)[illuminate/mail

The Illuminate Mail package.

5910.4M475](/packages/illuminate-mail)

PHPackages © 2026

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