PHPackages                             johanndms/expo-server-sdk-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. johanndms/expo-server-sdk-php

ActiveLibrary

johanndms/expo-server-sdk-php
=============================

Forked - Server-side library for working with Expo using PHP

v2.2(9mo ago)012MITPHPPHP &gt;=7.3

Since Jul 17Pushed 9mo agoCompare

[ Source](https://github.com/johanndms/expo-server-sdk-php)[ Packagist](https://packagist.org/packages/johanndms/expo-server-sdk-php)[ Docs](https://github.com/johanndms/expo-server-sdk-php)[ RSS](/packages/johanndms-expo-server-sdk-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

expo-server-sdk-php
===================

[](#expo-server-sdk-php)

Server-side library for working with Expo using PHP - Forked from ctwillie and added PHP 8 nullable requirements.

If you have any problems with the code in this repository, feel free to [open an issue](https://github.com/johanndms/expo-server-sdk-php/issues) or make a PR!

Table of Contents- [expo-server-sdk-php](#expo-server-sdk-php)
    - [Testing](#testing)
    - [Installation](#installation)
    - [Use Cases](#use-cases)
    - [Composing a message](#composing-a-message)
    - [Sending a push notification](#sending-a-push-notification)
    - [Channel subscriptions](#channel-subscriptions)
    - [Expo responses](#expo-responses)
    - [Handling unregistered devices](#handling-unregistered-devices)
    - [Retrieving push receipts](#retrieving-push-receipts)
    - [Changelog](#changelog)
    - [Contributing](#contributing)
    - [License](#license)
    - [Credits](#credits)

Testing
-------

[](#testing)

You can run the test suite via composer:

```
composer test
```

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

[](#installation)

You can install the package via composer:

```
composer require johanndms/expo-server-sdk-php
```

Use Cases
---------

[](#use-cases)

This package was written with two main use cases in mind.

1. Sending push notification messages to one or more recipients, then you're done! The most obvious use case.
2. And channel subscriptions, used to subscribe one or more tokens to a channel, then send push notifications to all tokens subscribed to that channel. Subscriptions are persisted until a token unsubscribes from a channel. Maybe unsubscribing upon the end users request.

Keep this in mind as you decide which is the best use case for your back end.

Composing a message
-------------------

[](#composing-a-message)

Compose a push notification message to send using options from the [Expo docs](https://docs.expo.dev/push-notifications/sending-notifications/#message-request-format).

```
use ExpoSDK\ExpoMessage;

/**
 * Create messages fluently and/or pass attributes to the constructor
 */
$message = (new ExpoMessage([
    'title' => 'initial title',
    'body' => 'initial body',
]))
    ->setTitle('This title overrides initial title')
    ->setBody('This notification body overrides initial body')
    ->setData(['id' => 1])
    ->setChannelId('default')
    ->setBadge(0)
    ->playSound();
```

Sending a push notification
---------------------------

[](#sending-a-push-notification)

Compose a message then send to one or more recipients.

```
use ExpoSDK\Expo;
use ExpoSDK\ExpoMessage;

/**
 * Composed messages, see above
 * Can be an array of arrays, ExpoMessage instances will be made internally
 */
$messages = [
    [
        'title' => 'Test notification',
        'to' => 'ExponentPushToken[xxxx-xxxx-xxxx]',
    ],
    new ExpoMessage([
        'title' => 'Notification for default recipients',
        'body' => 'Because "to" property is not defined',
    ]),
];

/**
 * These recipients are used when ExpoMessage does not have "to" set
 */
$defaultRecipients = [
    'ExponentPushToken[xxxx-xxxx-xxxx]',
    'ExponentPushToken[yyyy-yyyy-yyyy]'
];

(new Expo)->send($messages)->to($defaultRecipients)->push();
```

Channel subscriptions
---------------------

[](#channel-subscriptions)

Subscribe tokens to a channel, then push notification messages to that channel. Subscriptions are persisted internally in a local file so you don't have to worry about this yourself. Unsubscribe the token from the channel at any time to stop messages to that recipient.

> ⚠️ **If you are are running multiple app servers**: Be very careful here! Channel subscriptions are stored in an internal local file. Subscriptions will not be shared across multiple servers.

```
/**
 * Specify the file driver to persist subscriptions internally.
 */
use ExpoSDK\Expo;

$expo = Expo::driver('file');

// composed message, see above
$message;

$recipients = [
    'ExponentPushToken[xxxx-xxxx-xxxx]',
    'ExponentPushToken[yyyy-yyyy-yyyy]'
];

// name your channel anything you'd like
$channel = 'news-letter';
// the channel will be created automatically if it doesn't already exist
$expo->subscribe($channel, $recipients);

$expo->send($message)->toChannel($channel)->push();

// you can unsubscribe one or more recipients from a channel.
$expo->unsubscribe($channel, $recipients);
```

Expo responses
--------------

[](#expo-responses)

Get the data returned from successful responses from the Expo server.

```
$response = $expo->send($message)->to($recipients)->push();

$data = $response->getData();
```

Handling unregistered devices
-----------------------------

[](#handling-unregistered-devices)

Expo provides a macro for handling tokens that have DeviceNotRegistered error in the Expo response. You can register a callback before sending your messages to handle these unregistered tokens.

You only need to register the handler once as it will be applied to all Expo instances.

```
use ExpoSDK\Expo;

Expo::addDevicesNotRegisteredHandler(function ($tokens) {
    // this callback is called once and receives an array of unregistered tokens
});

$expo1 = new Expo();
$expo1->send(...)->push(); // will call your callback

$expo2 = new Expo();
$expo2->send(...)->push(); // will also call your callback
```

Retrieving push receipts
------------------------

[](#retrieving-push-receipts)

Retrieve the push receipts using the ticket ids from the Expo server.

```
$ticketIds = [
    'xxxx-xxxx-xxxx-xxxx',
    'yyyy-yyyy-yyyy-yyyy'
];

$response = $expo->getReceipts($ticketIds);
$data = $response->getData();
```

Changelog
---------

[](#changelog)

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

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

[](#contributing)

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

License
-------

[](#license)

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

Credits
-------

[](#credits)

- [Cedric Twillie](https://github.com/ctwillie)
- [All Contributors](../../contributors)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance55

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity31

Early-stage or recently created project

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

297d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d06e0c90928d35f60d3ae00410d1df8dd9ba4cbe6602c91ecdcb162c9838cc0?d=identicon)[johanndm](/maintainers/johanndm)

---

Tags

phpexpoexpo-server-sdk-php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/johanndms-expo-server-sdk-php/health.svg)

```
[![Health](https://phpackages.com/badges/johanndms-expo-server-sdk-php/health.svg)](https://phpackages.com/packages/johanndms-expo-server-sdk-php)
```

###  Alternatives

[ctwillie/expo-server-sdk-php

Server-side library for working with Expo using PHP

63686.3k1](/packages/ctwillie-expo-server-sdk-php)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)

PHPackages © 2026

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