PushRadar's official PHP library, wrapping the PushRadar API.
PHP
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Build Status Latest Stable Version Total Downloads License

Introduction

PushRadar is a realtime notifications API service for the web. The service uses a simple publish-subscribe model, allowing you to broadcast "notifications" on "channels" that are subscribed to by one or more clients. Notifications are pushed in realtime to those clients.

PushRadar features advanced targeting options, including the ability to target clients by actions they have taken on your website or web app, geographical location (countries & continents), IP address, web browser and user ID.

This is PushRadar's official PHP library.

Prerequisites

In order to use this library, please ensure that you have the following:

Composer

The easiest way to get up and running is to install the library using Composer. Run the following command in your console:

composer require pushradar/pushradar-php

To begin using the library, create an index.php file that loads Composer's autoloader from the /vendor folder:

require_once('vendor/autoload.php');

Manual Installation

Alternatively, if you do not wish to use Composer, you can download the latest release, and require_once the init.php file:

require_once('path/to/pushradar-php/init.php');

Dependencies

In order to use this library, please ensure you have enabled the following PHP extensions:

If you are using Composer, it will automatically check whether those extensions are enabled on your system.

Getting Started

"Hello World!" example:

$radar = new \PushRadar\PushRadar("your-secret-key");
$radar->broadcast("test-channel", array("message" => "Hello World!"));

Receiving Notifications

To subscribe to channels and receive notifications broadcast on them, check out the documentation for PushRadar's JavaScript client library.

Fluent Syntax

The library supports fluent method chaining to structure broadcasts. For example, to target a notification to website visitors in the US who have not used live chat before:

$radar->targetCountry("US")->targetNotAction("live-chat")->broadcast("test-channel", array(
    "message" => "Would you like to talk to one of our customer support team members on live chat?"));

Please note that targeting options reset after each call to the broadcast method.

Documentation

Full documentation for PushRadar's PHP library can be found at: www.pushradar.com/docs/php.