PHPackages                             pushpad/pushpad-php - 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. pushpad/pushpad-php

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

pushpad/pushpad-php
===================

Pushpad PHP Library

v3.1.0(7mo ago)26138.1k↓28%9MITPHPPHP &gt;=8.0.0CI passing

Since Feb 12Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/pushpad/pushpad-php)[ Packagist](https://packagist.org/packages/pushpad/pushpad-php)[ Docs](https://pushpad.xyz)[ RSS](/packages/pushpad-pushpad-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (25)Used By (0)

Pushpad - Web Push Notifications
================================

[](#pushpad---web-push-notifications)

[![Build Status](https://github.com/pushpad/pushpad-php/workflows/CI/badge.svg)](https://github.com/pushpad/pushpad-php/workflows/CI/badge.svg)[![Latest Stable Version](https://camo.githubusercontent.com/8bcc2689803b4200d19d29d2d89dc03fbb18df73b4cb0f674f9b1a1f70d21576/68747470733a2f2f706f7365722e707567782e6f72672f707573687061642f707573687061642d7068702f76)](//packagist.org/packages/pushpad/pushpad-php)[![Total Downloads](https://camo.githubusercontent.com/9eed04595ac4f151346a9a4e2f40fe37f10002a34fedf390d1d7987437cf67b3/68747470733a2f2f706f7365722e707567782e6f72672f707573687061642f707573687061642d7068702f646f776e6c6f616473)](//packagist.org/packages/pushpad/pushpad-php)[![License](https://camo.githubusercontent.com/67a18010190396b0b6cd21e91db31b62722e61e247f63d43b4b08a530d8f4f01/68747470733a2f2f706f7365722e707567782e6f72672f707573687061642f707573687061642d7068702f6c6963656e7365)](//packagist.org/packages/pushpad/pushpad-php)

[Pushpad](https://pushpad.xyz) is a service for sending push notifications from websites and web apps. It uses the **Push API**, which is supported by all major browsers (Chrome, Firefox, Opera, Edge, Safari).

Notifications are delivered in real time even when the users are not on your website and you can target specific users or send bulk notifications.

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

[](#installation)

### Composer

[](#composer)

This package requires PHP 8.0+ with the `curl` extension.

Install the SDK via [Composer](https://getcomposer.org/):

```
composer require pushpad/pushpad-php
```

Then include Composer's autoloader:

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

### Manual installation

[](#manual-installation)

Clone the repository and require the bootstrap file in your project:

```
git clone https://github.com/pushpad/pushpad-php.git
```

```
require_once __DIR__ . '/path/to/pushpad-php/init.php';
```

Getting started
---------------

[](#getting-started)

First sign up to Pushpad and create a project.

Configure the SDK with your credentials before you make any API calls:

```
Pushpad\Pushpad::$authToken = '5374d7dfeffa2eb49965624ba7596a09';
Pushpad\Pushpad::$projectId = 123; // set a default project (optional)
```

- `authToken` can be created in the account settings.
- `projectId` is shown in the project settings. If you work with multiple projects you can pass a different project id to individual method calls instead of configuring the global default.

Collecting user subscriptions
-----------------------------

[](#collecting-user-subscriptions)

Use the JavaScript SDK to subscribe users to push notifications (see the [getting started guide](https://pushpad.xyz/docs/pushpad_pro_getting_started)).

When you need to sign a `uid`, generate the HMAC signature with:

```
$signature = Pushpad\Pushpad::signatureFor((string) $currentUserId);
```

Sending push notifications
--------------------------

[](#sending-push-notifications)

Use `Pushpad\Notification::create()` (or the `send()` alias) to create and send a notification:

```
$response = Pushpad\Notification::create([
    // required content
    'body' => 'Hello world!',

    // optional fields
    'title' => 'Website Name',
    'target_url' => 'https://example.com',
    'icon_url' => 'https://example.com/assets/icon.png',
    'badge_url' => 'https://example.com/assets/badge.png',
    'image_url' => 'https://example.com/assets/image.png',
    'ttl' => 604800,
    'require_interaction' => true,
    'silent' => false,
    'urgent' => false,
    'custom_data' => '123',
    'actions' => [
        [
            'title' => 'My Button 1',
            'target_url' => 'https://example.com/button-link',
            'icon' => 'https://example.com/assets/button-icon.png',
            'action' => 'myActionName',
        ],
    ],
    'starred' => true,
    'send_at' => (new DateTimeImmutable('+1 hour'))->format(DATE_ATOM),
    'custom_metrics' => ['examples', 'another_metric'],

    // targeting options
    'uids' => ['user-1', 'user-2'],
    'tags' => ['segment1', 'segment2'],
]);
```

- Omit `uids` and `tags` to broadcast to everyone.
- If you set `uids` and some users are not subscribed to notifications, Pushpad ignores them.
- Use boolean expressions inside `tags` for complex segments (e.g. `'zip_code:28865 && !optout:local_events'`).
- Scheduled notifications require an ISO 8601 timestamp in `send_at` (as produced by `DateTimeInterface::format(DATE_ATOM)`).
- You can set default values for most notification fields in the project settings.
- Refer to the [REST API docs](https://pushpad.xyz/docs/rest_api#notifications_api_docs) for more details about the notification fields and their usage.

The response includes useful information:

```
// Notification ID
$notificationId = $response['id'];

// Estimated number of devices that will receive the notification
// Not available for notifications that use send_at
$estimatedReach = $response['scheduled'];

// Available only if you specify some user IDs (uids) in the request:
// it indicates which of those users are subscribed to notifications.
// Not available for notifications that use send_at
$reachedUids = $response['uids'];

// The time when the notification will be sent.
// Available for notifications that use send_at
$scheduledAt = $response['send_at'];
```

Getting push notification data
------------------------------

[](#getting-push-notification-data)

Fetch a single notification and inspect its attributes:

```
$notification = Pushpad\Notification::find(42);

echo $notification->title; // "Foo Bar"
echo $notification->target_url; // "https://example.com"
echo $notification->ttl; // 604800
echo $notification->created_at; // ISO 8601 string
echo $notification->successfully_sent_count; // 4
echo $notification->opened_count; // 2

// ... and many other attributes
print_r($notification->toArray());
```

List notifications for a project (pagination supported through the `page` query parameter):

```
$notifications = Pushpad\Notification::findAll(['page' => 1]);

foreach ($notifications as $item) {
    printf("Notification %d: %s\n", $item->id, $item->title);
}
```

Pass the project id as the second argument when you prefer not to rely on the globally configured `Pushpad\Pushpad::$projectId`:

```
Pushpad\Notification::findAll([], projectId: 456);

```

If you need to refresh a previously loaded notification, call `$notification->refresh()` to hydrate the latest data from the API.

Scheduled notifications
-----------------------

[](#scheduled-notifications)

Create a notification that will be sent later:

```
Pushpad\Notification::create([
    'body' => 'This notification will be sent after 60 seconds',
    'send_at' => (new DateTimeImmutable('+60 seconds'))->format(DATE_ATOM),
]);
```

Cancel a scheduled notification when it is still pending:

```
$notification = Pushpad\Notification::find(5);
$notification->cancel();
```

Getting subscription count
--------------------------

[](#getting-subscription-count)

Retrieve the number of subscriptions associated with a project, optionally filtered by user IDs or tags:

```
$total = Pushpad\Subscription::count();
$byUser = Pushpad\Subscription::count(['uids' => ['user1']]);
$byTags = Pushpad\Subscription::count(['tags' => ['sports && travel']]);
$combined = Pushpad\Subscription::count(['uids' => ['user1'], 'tags' => ['sports && travel']], 5);
```

The second argument lets you override the project id if you did not configure `Pushpad\Pushpad::$projectId` or you need to switch project on the fly.

Getting push subscription data
------------------------------

[](#getting-push-subscription-data)

Fetch subscriptions with optional filters and pagination:

```
$subscriptions = Pushpad\Subscription::findAll(['tags' => ['sports'], 'page' => 2]);

foreach ($subscriptions as $subscription) {
    echo $subscription->id . PHP_EOL;
    // ...
}
```

Load a specific subscription when you already know its id:

```
$subscription = Pushpad\Subscription::find(123);

echo $subscription->id;
echo $subscription->project_id;
echo $subscription->endpoint;
echo $subscription->uid;
echo $subscription->tags;
echo $subscription->last_click_at;
echo $subscription->created_at;

// ... and many other attributes
print_r($subscription->toArray());
```

Updating push subscription data
-------------------------------

[](#updating-push-subscription-data)

Although tags and user IDs are usually managed from the JavaScript SDK, you can also update them from server:

```
$subscriptions = Pushpad\Subscription::findAll(['uids' => ['user1']]);

foreach ($subscriptions as $subscription) {
    $tags = $subscription->tags ?? [];
    $tags[] = 'another_tag';

    $subscription->update([
        'uid' => 'myuser1',
        'tags' => array_values(array_unique($tags)),
    ]);
}
```

Importing push subscriptions
----------------------------

[](#importing-push-subscriptions)

To import existing subscriptions or seed test data use `Pushpad\Subscription::create()`:

```
$subscription = Pushpad\Subscription::create([
    'endpoint' => 'https://example.com/push/f7Q1Eyf7EyfAb1',
    'p256dh' => 'BCQVDTlYWdl05lal3lG5SKr3VxTrEWpZErbkxWrzknHrIKFwihDoZpc_2sH6Sh08h-CacUYI-H8gW4jH-uMYZQ4=',
    'auth' => 'cdKMlhgVeSPzCXZ3V7FtgQ==',
    'uid' => 'exampleUid',
    'tags' => ['exampleTag1', 'exampleTag2'],
]);
```

Typically subscriptions are collected from the browser using the [JavaScript SDK](https://pushpad.xyz/docs/javascript_sdk_reference); server-side creation should be reserved for migrations and special workflows.

Deleting push subscriptions
---------------------------

[](#deleting-push-subscriptions)

Delete subscriptions programmatically (use with care, the operation is irreversible):

```
$subscription = Pushpad\Subscription::find(123);
$subscription->delete();
```

Managing projects
-----------------

[](#managing-projects)

Projects can also be managed via the API for automation use cases:

```
$project = Pushpad\Project::create([
    'sender_id' => 123,
    'name' => 'My project',
    'website' => 'https://example.com',
    'icon_url' => 'https://example.com/icon.png',
    'badge_url' => 'https://example.com/badge.png',
    'notifications_ttl' => 604800,
    'notifications_require_interaction' => false,
    'notifications_silent' => false,
]);

$projects = Pushpad\Project::findAll();

$project = Pushpad\Project::find(123);
$project->update(['name' => 'The New Project Name']);
$project->delete();
```

Managing senders
----------------

[](#managing-senders)

Senders hold the VAPID credentials used for Web Push:

```
$sender = Pushpad\Sender::create([
    'name' => 'My sender',
    // omit the keys below to let Pushpad generate them automatically
    // 'vapid_private_key' => '-----BEGIN EC PRIVATE KEY----- ...',
    // 'vapid_public_key' => '-----BEGIN PUBLIC KEY----- ...',
]);

$senders = Pushpad\Sender::findAll();

$sender = Pushpad\Sender::find(987);
$sender->update(['name' => 'The New Sender Name']);
$sender->delete();
```

License
-------

[](#license)

The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance64

Regular maintenance activity

Popularity44

Moderate usage in the ecosystem

Community11

Small or concentrated contributor base

Maturity78

Established project with proven stability

 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 ~160 days

Recently: every ~329 days

Total

23

Last Release

221d ago

Major Versions

v0.4.0 → v1.0.02016-07-23

v1.8.0 → v2.0.02022-11-30

v2.1.0 → v3.0.02025-10-07

PHP version history (2 changes)v0.1.0PHP &gt;=5.3.3

v2.1.0PHP &gt;=8.0.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/383556b3722e23e0f52148506bf5702297ffd42702cd5a622029dca338c88bed?d=identicon)[collimarco](/maintainers/collimarco)

---

Top Contributors

[![collimarco](https://avatars.githubusercontent.com/u/90962?v=4)](https://github.com/collimarco "collimarco (79 commits)")

---

Tags

notificationspush-notificationsweb-pushapinotificationspush notificationsWeb Pushpushpad

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/pushpad-pushpad-php/health.svg)

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

###  Alternatives

[bentools/webpush-bundle

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

71274.3k](/packages/bentools-webpush-bundle)[tomatophp/filament-accounts

Manage your multi accounts inside your app using 1 table with multi auth and a lot of integrations

748.3k7](/packages/tomatophp-filament-accounts)

PHPackages © 2026

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