pusher/pusher-push-notifications

Maintainers

👁 pusher

Package info

github.com/pusher/push-notifications-php

pkg:composer/pusher/pusher-push-notifications

Statistics

Installs: 2 711 375

Dependents: 9

Suggesters: 0

Stars: 56

Open Issues: 4

2.0.1 2026-03-02 14:46 UTC

Requires

Requires (Dev)

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT b71748b72a1bc7d6a5ca15fafa976b829377c193


README

👁 Build Status

PHP SDK for Pusher Beams

PHP server library for publishing notifications through Pusher Beams.

Check https://docs.pusher.com/beams/reference/server-sdk-php for more information.

NOTE: This library requires a PHP version of 8.0 or greater

Installation

Get Composer, then get the pusher/pusher-push-notifications Composer package:

$ composer require pusher/pusher-push-notifications

This SDK depends on the JSON PHP module.

Use

Configuring the SDK for your instance

<?php
require __DIR__ . '/vendor/autoload.php';

$pushNotifications = new \Pusher\PushNotifications\PushNotifications(array(
 "instanceId" => "YOUR_INSTANCE_ID_HERE",
 "secretKey" => "YOUR_SECRET_HERE",
));

Publishing to Device Interests

You can broadcast notifications to groups of subscribed devices using Device Interests:

$publishResponse = $pushNotifications->publishToInterests(
 ["donuts"],
 [
 "apns" => [
 "aps" => [
 "alert" => "Hello!",
 ],
 ],
 "fcm" => [
 "notification" => [
 "title" => "Hello!",
 "body" => "Hello, world!",
 ],
 ],
 ]
);

echo("Published with Publish ID: " . $publishResponse->publishId . "\n");

Publishing to Device Interests along with data

You can broadcast notifications with some data to groups of subscribed devices using Device Interests:

$publishResponse = $pushNotifications->publishToInterests(
 ["donuts"],
 [
 "apns" => [
 "aps" => [
 "alert" => "Hello!",
 ],
 ],
 "fcm" => [
 "notification" => [
 "title" => "Hello!",
 "body" => "Hello, world!",
 ],
 "data" => [
 "name" => "adam",
 "type" => "user",
 ],
 ],
 ]
);

echo("Published with Publish ID: " . $publishResponse->publishId . "\n");

Publishing to Authenticated Users

Securely send notifications to individual users of your application using Authenticated Users:

$publishResponse = $pushNotifications->publishToUsers(
 ["user-0001"],
 [
 "apns" => [
 "aps" => [
 "alert" => "Hello!",
 ],
 ],
 "fcm" => [
 "notification" => [
 "title" => "Hello!",
 "body" => "Hello, world!",
 ],
 ],
 ]
);

echo("Published with Publish ID: " . $publishResponse->publishId . "\n");