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

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

zupago/webpush
==============

Web Push Notifications driver for Laravel.

03PHP

Since Nov 17Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (2)Used By (0)

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

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

[![Latest Version on Packagist](https://camo.githubusercontent.com/da7d5293b1bbd6a1e0203566b72f6aed6e9755341ce2558c57cc4d2f740f71e9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a757061676f2f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zupago/webpush)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/2202e8b4b9479e380ec91ac6ac400e077cd0f2eccf20dc07da57f95723aec53e/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7a757061676f2f776562707573682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/zupago/webpush)[![StyleCI](https://camo.githubusercontent.com/f37a889f49d525342a696749e09889d5a07274dfed22d4213eb176871766d8e8/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131303936353339312f736869656c64)](https://styleci.io/repos/110965391)[![SensioLabsInsight](https://camo.githubusercontent.com/1aa199e49ff33346fe57c95c8398d25c34b86ff99a6edfe00eb0448ed2170c0d/68747470733a2f2f696d672e736869656c64732e696f2f73656e73696f6c6162732f692f33306435376130632d303664622d343565342d393766632d3265313634636263613534662e7376673f7374796c653d666c61742d737175617265)](https://insight.sensiolabs.com/projects/30d57a0c-06db-45e4-97fc-2e164cbca54f)[![Quality Score](https://camo.githubusercontent.com/0b658dd78b357d8140b4b552841556f47011ab15ac8372cada1a31ef38f821ec/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7a757061676f2f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/zupago/webpush)[![Code Coverage](https://camo.githubusercontent.com/4ff8e0088d9e9b6da3081bb6f9a16fd202f84b4bc59b318fcc99d5997798fefb/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7a757061676f2f776562707573682f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/zupago/webpush/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/6f08e54054b9ea87be73ea0a8bee634404e9ff275031f81d11b473d16c5ca2c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a757061676f2f776562707573682e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zupago/webpush)

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

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

[](#installation)

You can install the package via composer:

```
composer require zupago/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 with (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 webpushMessage::create()
            // ->id($notification->id)
            ->title('Approved!')
            ->icon('/approved-icon.png')
            ->body('Your account was approved!')
            ->action('View account', 'view_account');
    }
}
```

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

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

[](#browser-compatibility)

The [Push API](https://developer.mozilla.org/en/docs/Web/API/Push_API) currently works on Chrome and Firefox.

Changelog
---------

[](#changelog)

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

Testing
-------

[](#testing)

```
$ composer test
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

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

### Community

Maintainers

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

---

Top Contributors

[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")[![zupago-zz](https://avatars.githubusercontent.com/u/21144952?v=4)](https://github.com/zupago-zz "zupago-zz (1 commits)")

### Embed Badge

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

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

###  Alternatives

[tijsverkoyen/css-to-inline-styles

CssToInlineStyles is a class that enables you to convert HTML-pages/files into HTML-pages/files with inline styles. This is very useful when you're sending emails.

5.8k505.3M227](/packages/tijsverkoyen-css-to-inline-styles)[minishlink/web-push

Web Push library for PHP

1.9k12.0M53](/packages/minishlink-web-push)[laravel-notification-channels/twilio

Provides Twilio notification channel for Laravel

2587.7M12](/packages/laravel-notification-channels-twilio)[spatie/url-signer

Generate a url with an expiration date and signature to prevent unauthorized access

4422.3M16](/packages/spatie-url-signer)[mattketmo/email-checker

Throwaway email detection library

2742.0M5](/packages/mattketmo-email-checker)[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)
