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

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

zareshahi/webpush
=================

Web Push Notifications driver for Laravel.

v1.0.0(3y ago)0108MITPHPPHP ^8.1

Since Apr 30Pushed 3y agoCompare

[ Source](https://github.com/ali-zareshai/webpush)[ Packagist](https://packagist.org/packages/zareshahi/webpush)[ Docs](https://github.com/laravel-notification-channels/webpush)[ RSS](/packages/zareshahi-webpush/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)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)[![Build Status](https://github.com/laravel-notification-channels/webpush/workflows/tests/badge.svg)](https://github.com/laravel-notification-channels/webpush/workflows/tests/badge.svg)[![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 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 for [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')
            ->options(['TTL' => 1000]);
            // ->data(['id' => $notification->id])
            // ->badge()
            // ->dir()
            // ->image()
            // ->lang()
            // ->renotify()
            // ->requireInteraction()
            // ->tag()
            // ->vibrate()
    }
}
```

You can find the available options [here](https://github.com/web-push-libs/web-push-php#notifications-and-default-options).

### Save/Update Subscriptions

[](#saveupdate-subscriptions)

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

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

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

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);
```

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

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

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

Unknown

Total

1

Last Release

1114d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/33b1c3fa90ec64c69f9b3eb28b78701994e4c63e0dfb70afc438f89d8183a659?d=identicon)[ali\_zareshahi](/maintainers/ali_zareshahi)

---

Top Contributors

[![cretueusebiu](https://avatars.githubusercontent.com/u/1517945?v=4)](https://github.com/cretueusebiu "cretueusebiu (98 commits)")[![joostdebruijn](https://avatars.githubusercontent.com/u/1844089?v=4)](https://github.com/joostdebruijn "joostdebruijn (15 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (14 commits)")[![alberto-bottarini](https://avatars.githubusercontent.com/u/1442934?v=4)](https://github.com/alberto-bottarini "alberto-bottarini (5 commits)")[![web-flow](https://avatars.githubusercontent.com/u/19864447?v=4)](https://github.com/web-flow "web-flow (2 commits)")[![ali-zareshai](https://avatars.githubusercontent.com/u/22685427?v=4)](https://github.com/ali-zareshai "ali-zareshai (2 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (2 commits)")[![themsaid](https://avatars.githubusercontent.com/u/4332182?v=4)](https://github.com/themsaid "themsaid (2 commits)")[![themustafaomar](https://avatars.githubusercontent.com/u/46113191?v=4)](https://github.com/themustafaomar "themustafaomar (2 commits)")[![vesper8](https://avatars.githubusercontent.com/u/816028?v=4)](https://github.com/vesper8 "vesper8 (2 commits)")[![jadamec](https://avatars.githubusercontent.com/u/19595874?v=4)](https://github.com/jadamec "jadamec (1 commits)")[![JapSeyz](https://avatars.githubusercontent.com/u/2234034?v=4)](https://github.com/JapSeyz "JapSeyz (1 commits)")[![JayBizzle](https://avatars.githubusercontent.com/u/340752?v=4)](https://github.com/JayBizzle "JayBizzle (1 commits)")[![bhulsman](https://avatars.githubusercontent.com/u/612651?v=4)](https://github.com/bhulsman "bhulsman (1 commits)")[![atymic](https://avatars.githubusercontent.com/u/50683531?v=4)](https://github.com/atymic "atymic (1 commits)")[![martijnb92](https://avatars.githubusercontent.com/u/708544?v=4)](https://github.com/martijnb92 "martijnb92 (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)")[![nonovd](https://avatars.githubusercontent.com/u/12936673?v=4)](https://github.com/nonovd "nonovd (1 commits)")[![oele-dev](https://avatars.githubusercontent.com/u/1950715?v=4)](https://github.com/oele-dev "oele-dev (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[laravel-notification-channels/webpush

Web Push Notifications driver for Laravel.

7984.5M16](/packages/laravel-notification-channels-webpush)[laravel-notification-channels/telegram

Telegram Notifications Channel for Laravel

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

FCM (Firebase Cloud Messaging) Notifications Driver for Laravel

5917.0M16](/packages/laravel-notification-channels-fcm)[s-ichikawa/laravel-sendgrid-driver

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

4139.3M1](/packages/s-ichikawa-laravel-sendgrid-driver)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[laravel-notification-channels/apn

Apple APN Push Notification Channel

2021.9M4](/packages/laravel-notification-channels-apn)

PHPackages © 2026

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