Search by

PHP client SDK for the Falcon Notification Gateway

v0.1.0 2026-08-07 14:05 UTC

This package is auto-updated.

Last update: 2026-09-07 14:29:59 UTC


README

PHP client SDK for the Falcon Notification Gateway.

Requirements

  • PHP >= 8.0
  • ext-curl
  • ext-json

Installation

composer require falcongateway/notify

Quick Start

use FalconGateway\Notify\FalconClient;
use FalconGateway\Notify\Channels\SMS;
use FalconGateway\Notify\Channels\Email;

$client = new FalconClient('your-platform-token');

// Send SMS
$result = $client->send(new SMS('Hello!'), ['+255712345678']);

// Send Email
$result = $client->send(new Email('Subject', 'Body text'), ['user@example.com']);

echo $result->message; // "Dispatched successfully."

Channels

SMS

new SMS('Your OTP is 1234')

Email

(new Email('Subject', 'Plain text body'))
    ->html('<b>HTML body</b>')
    ->fromName('Falcon')
    ->fromEmail('noreply@example.com')
    ->replyTo('support@example.com')
    ->attachment(file_get_contents('invoice.pdf'), 'invoice.pdf')

Push Notification

(new Push('Title', 'Body'))
    ->data(['order_id' => '123'])
    ->imageUrl('https://example.com/image.png')

WhatsApp

// Text message
new WhatsApp('Hello from Falcon!')

// Template message
(new WhatsApp(''))->template('otp_v1', ['1234', '5'])

Matrix

(new Matrix('Alert: server down'))
    ->html('<b>Alert:</b> server down')

Multi-Channel

$result = $client->send(
    [new SMS('Code: 1234'), new Email('OTP', 'Code: 1234')],
    [['phone' => '+255712345678', 'email' => 'user@example.com']]
);

Send to Phonebook

$result = $client->sendToPhonebook(new SMS('Broadcast message'), ['PB-ABCD12']);

Personalized Messages

$result = $client->sendMessages([
    [
        'recipient' => ['phone' => '+255712345678'],
        'channels'  => ['sms' => true],
        'content'   => ['sms' => ['text' => 'Hi Alice!']],
    ],
]);

Scheduling

use FalconGateway\Notify\Schedule\Schedule;

// One-time
$client->send(new SMS('Reminder'), $recipients, Schedule::once('2026-09-01T09:00:00Z'));

// Daily at 8 AM
$client->send(new SMS('Good morning!'), $recipients, Schedule::daily8am('Africa/Dar_es_Salaam'));

// Custom cron expression
$client->send(new SMS('Weekly'), $recipients, Schedule::cron('0 8 * * MON', 'Africa/Nairobi'));

// Interval (every N minutes)
$client->send(new SMS('Ping'), $recipients, Schedule::interval(30, 'UTC'));

Available presets: daily8am(), dailyNoon(), daily6pm(), everyHour(), every30min(), every15min(), weeklyMonday(), weeklyFriday(), monthlyFirst(), weekdays8am()

Error Handling

use FalconGateway\Notify\Exceptions\AuthException;
use FalconGateway\Notify\Exceptions\ValidationException;
use FalconGateway\Notify\Exceptions\ServerException;
use FalconGateway\Notify\Exceptions\NetworkException;

try {
    $client->send(new SMS('Hello'), $recipients);
} catch (AuthException $e) {
    // Invalid or inactive token (HTTP 403)
} catch (ValidationException $e) {
    // Bad request — check $e->getMessage() (HTTP 400)
} catch (ServerException $e) {
    // Gateway server error (HTTP 5xx)
} catch (NetworkException $e) {
    // Connection or timeout error
}

Full Documentation

https://falcongateway.all.tz/docs