A PHP library to send push notification through Firebase Cloud Messaging

2.3.0 2021-02-11 10:17 UTC

This package is auto-updated.

Last update: 2022-01-18 15:29:00 UTC


CI Coverage PHP Version Downloads Latest Stable Version License


A PHP library to send push notification with Firebase Cloud Messaging


Version 2.x of this library is a full rewrite to be compliant with HTTP v1 API. If you are on Legacy HTTP API, then you should consider using version 1.x


You can install Fcm using Composer:

composer require kerox/fcm

You will then need to:

  • run composer install to get these dependencies added to your vendor directory
  • add the autoloader to your application with this line: require('vendor/autoload.php');

Basic usage

use Kerox\Fcm\Fcm;
use Kerox\Fcm\Model\Message;
use Kerox\Fcm\Model\Message\Notification;

$fcm = new Fcm('<oauth_token>', '<project_id>');

// Create a notification
$notification = new Notification('Hello World');
$notification->setBody('My awesome Hello World!');

// Create the message
$message = new Message($notification);
    'data-1' => 'Lorem ipsum',
    'data-2' => '1234',
    'data-3' => 'true'

// Send the message and get the response
$response = $fcm->send()->message($message);


The documentation is available here