Skip to content

redjanym/php-firebase-cloud-messaging

This branch is 41 commits ahead of, 3 commits behind sngrl/php-firebase-cloud-messaging:master.

Folders and files

NameName
Last commit message
Last commit date
Jan 27, 2025
Jan 24, 2025
Jan 23, 2025
May 31, 2016
Jan 27, 2025
Apr 6, 2025

Repository files navigation

PHP Firebase Cloud Messaging

Buy Me a Coffee at ko-fi.com

PHP SDK for Firebase Cloud Messaging from Google, supporting HTTP V1.

See original Firebase docs: https://firebase.google.com/docs/

#Setup Install via Composer:

composer require redjanym/php-firebase-cloud-messaging

Or add this to your composer.json and run "composer update":

"require": {
    "redjanym/php-firebase-cloud-messaging": "2.*"
}

Send message to a Device

use RedjanYm\FCM\Client;
use RedjanYm\FCM\Notification;
use RedjanYm\FCM\Recipient\Device;

$serviceAccountPath = '/path/to/service-account.json';
$testToken = 'this-is-a-token';

$client = new Client($serviceAccountPath);
$recipient = new Device($testToken);
$notification = new Notification($recipient, 'Title', 'Body', ['key' => 'value']);

$client->send($notification);

Topic Support

The current version does not have support for Topics. We are going to add it on v2.1.

Migrating from V1.

Unfortunately V2 of this package introduces breaking changes. But the new structure of the SDK is still simple and very similar to the previous one. We are sure the migration is going to be very fast and easy.

Interpreting responses

Responses given on the HTTP requests are standard according to the FCM documentations. You may find detailed specifications in this links: