Google Firebase Push Notification(FCM) with PHP Library

This is the library for sent push notification using Google Firebase(FCM) Push Notification.


Use the Composer to install FCM-PUSH-Notify Library.

composer require farjihacker/fcm-push-notify


Step 1: Install using above command.

Step 2: Import/Use this Namespace.

use FirebaseNotify\Firebase; // Firebase Utility 
use FirebaseNotify\Push; // Create Message with JSON Formate

Step 3: Create Two Object.

$firebase = new Firebase("FIREBASE_API_KEY"); // Pass Your API Key as Param 
$push = new Push();

Step 4: Create JSON Data Object Using $push Object.

// optional payload 
$payload = array();
$payload['team'] = 'India';
$payload['score'] = '5.6';

// notification title
$title = "Test Title";
// notification message
$message = "MSG";
// push type - single user / topic
$push_type = "individual";
// whether to include to image or not
$include_image = "";

$push = new Push();
if ($include_image) {
} else {

Step 5: Sent Push Notification using $firebase object.

//Get JSON Object
$json = $push->getPush();
//echo "<pre>";

// User Token
$regId = "USER_TOKEN";
$response = $firebase->send($regId, $json);

// Enable this line to check firebase success/error response.

Leave a Reply

%d bloggers like this: