PHP Wrapper for using the OneSignal API.

0.0.3 2019-06-23 16:23 UTC

This package is auto-updated.

Last update: 2020-05-23 18:44:58 UTC


Build Status

OneSignal API

For reference - [https://documentation.onesignal.com/reference](OneSignal Docs).

Still work-in-progress.


Using Composer:

composer require mirovit/onesignal


Contributions are welcome, the only thing that is important for me is the expressive syntax and at some point when I've written tests - tests.


This package uses a fluent syntax, so it is very easy to read and understand the underlying code.


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

// By default, if a token is not passed in the constructor,
// the class will try to load the token from
// ONESIGNAL_API_KEY environment variable. The second param,
// the API endpoint is set as default value to
// https://onesignal.com/api/v1, which is the current endpoint:
$sdk = new Mirovit\OneSignal\OneSignal();
// or explicitly them:
$sdk = new Mirovit\OneSignal\OneSignal(
    'rest api key',
    'api endpoint'

// Retrieve player
$user = $sdk
            ->get('player-id', ['app_id' => 'app-id']);

Available endpoints


// https://documentation.onesignal.com/reference

// https://documentation.onesignal.com/reference#view-device
    ->get('player-id', ['app_id' => 'app-id']);

// https://documentation.onesignal.com/reference#edit-device
        // required
        'id'      => 'player-id',
        'app_id'     => 'app-id',
        // optional
        'identifier'      => '',
        'language'  => '',
        'test_type' => 1,
        // ... and more


// https://documentation.onesignal.com/reference#create-notification
        'app_id'   => 'app-id',
         'filters'  => (new \Mirovit\OneSignal\Filters())
             ->tag('key', 'value')
             ->tag('key', 'relation', 'value')
         'contents' => [
             'en' => 'test',