PHPackages                             valdeirpsr/firebasemessaging-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. valdeirpsr/firebasemessaging-php

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

valdeirpsr/firebasemessaging-php
================================

Send messages to mobile devices with Google Firebase.

0.5.1(9y ago)18.9kGNU GPLv3PHPPHP &gt;=5.4

Since Aug 18Pushed 3y ago3 watchersCompare

[ Source](https://github.com/valdeirpsr/FirebaseMessaging-PHP)[ Packagist](https://packagist.org/packages/valdeirpsr/firebasemessaging-php)[ Docs](https://github.com/valdeirpsr/FirebaseMessaging-PHP)[ RSS](/packages/valdeirpsr-firebasemessaging-php/feed)WikiDiscussions master Synced today

READMEChangelog (3)Dependencies (2)Versions (3)Used By (0)

ValdeirPsr/FirebaseMessaging-PHP
================================

[](#valdeirpsrfirebasemessaging-php)

Send messages to mobile devices with Google Firebase.

### Installation

[](#installation)

`composer require valdeirpsr/firebasemessaging-php`

### Sending A Basic Notification

[](#sending-a-basic-notification)

```
require "vendor/autoload.php";

use FirebaseMessaging\FirebaseMessaging;
use FirebaseMessaging\FirebaseNotification;
use FirebaseMessaging\FirebaseCondition;

$notification = new FirebaseNotification();
$notification->setTitle("Run!! New video");
$notification->setBody("Duelo de MC's - FINAL - Thaik vs Din");

$messaging = new FirebaseMessaging("serverKey");
$messaging->setTo("/topics/RapHipHop");
$messaging->setOperacionalSystem(FirebaseMessaging::OS_ANDROID);
$messaging->setNotification($notification);
$messaging->send();
```

Sending A Complete Notification
===============================

[](#sending-a-complete-notification)

```
require "vendor/autoload.php";

use FirebaseMessaging\FirebaseMessaging;
use FirebaseMessaging\FirebaseNotification;
use FirebaseMessaging\FirebaseCondition;

$notification = new FirebaseNotification();
$notification->setTitle("Run!! New video");
$notification->setBody("Duelo de MC's - FINAL - Thaik vs Din");
$notification->setIcon("custom_logo");
$notification->setTag("valdeirpsr_1");
$notification->setColor("#E91E63");
$notification->setClickAction("OPEN_ACTIVITY_VIDEO");
$notification->setSound("sound_notification");

$condition = new FirebaseCondition("RapHipHop");
$condition->openAnd("DouglasDin");
$condition->orInTopics("Thaik");
$condition->closeAnd();
// output: 'RapHipHop' in topics && ('DouglasDin' in Topics || 'Thaik' in Topics)

$messaging = new FirebaseMessaging("serverKey");
$messaging->setCondition($condition);
$messaging->setPriority(FirebaseMessaging::PRIORITY_HIGH);
$messaging->setTimeToLive(2419200);
$messaging->setOperacionalSystem(FirebaseMessaging::OS_BOTH);
$messaging->setNotification($notification);
$messaging->setRestrictedPackageName("br.com.valdeirsantana.test");
$messaging->setCollapseKey("video_new");
$messaging->setDelayWhileIdle(false);
$messaging->setDevelopmentMode(false);
$messaging->setData([
    "video_id" => "ZDz-5fQAIo4",
    "title" => "Duelo de MC's - FINAL - Thaik vs Din :: Tradicional - 23/11/12",
    "channel" => "Indie BH",
    "channel_url" => "https://www.youtube.com/channel/UCBkYx1zP0aOaMXsp9As75Tg",
    "channel_id" => "UCBkYx1zP0aOaMXsp9As75Tg",
    "thumbnail" => [
        "default" => [
            "url" => "https://i.ytimg.com/vi/ZDz-5fQAIo4/default.jpg",
            "width" => "120",
            "height" => "90"
        ],
        "high" => [
            "url" => "https://i.ytimg.com/vi/ZDz-5fQAIo4/mqdefault.jpg",
            "width" => "320",
            "height" => "180"
        ],
        "high" => [
            "url" => "https://i.ytimg.com/vi/ZDz-5fQAIo4/hqdefault.jpg",
            "width" => "480",
            "height" => "360"
        ],
        "standard" => [
            "url" => "https://i.ytimg.com/vi/ZDz-5fQAIo4/sddefault.jpg",
            "width" => "640",
            "height" => "480"
        ],
        "maxres" => [
            "url" => "https://i.ytimg.com/vi/ZDz-5fQAIo4/maxresdefault.jpg",
            "width" => "1920",
            "height" => "1080"
        ]
    ]
]);

$messaging->send();
```

### Set the device that will receive the notification

[](#set-the-device-that-will-receive-the-notification)

This parameter specifies the recipient of a message.

The value must be a register token, a notification key or a topic. Do not set this field to send multiple topics, see **FirebaseMessaging::setCondition** for it.

```
$messaging->setTo("RegistrationToken");
$messaging->setTo("/topics/RapHipHop");
```

### Set the devices that will receive the notification

[](#set-the-devices-that-will-receive-the-notification)

This method specifies a list of devices (registration tokens or IDs) that receive a multicast message. It must contain between 1 and 1,000 record tokens.

```
$messaging->setRegistrationIds([
    "RegistrationToken#1",
    "RegistrationToken#2",
    "RegistrationToken#3",
    "RegistrationToken#4",
]);
```

### Set the priority of the notification

[](#set-the-priority-of-the-notification)

By default, messages are sent with normal priority. Normal priority optimizes client application battery consumption and should always be used except when immediate delivery is required. For messages with normal priority, the application can get the message late unspecified.

When a message is sent with high priority, it is sent immediately and the application can trigger a device suspended and open a network connection to your server.

```
$messaging->setPriority(FirebaseMessaging::PRIORITY_HIGH);
```

### Set a delay for idle devices.

[](#set-a-delay-for-idle-devices)

When this parameter is set to true, the message must not be sent to the device is inactive.

Default: false

```
$messaging->setDelayWhileIdle(true);
```

### Sending Data to Device

[](#sending-data-to-device)

The key should not be a reserved word ("of" or any word beginning with "google" or "gcm"). Do not use any of the words defined in this table (as collapse\_key).

They are recommended values in string types. It is necessary to convert the values to objects or other types without string data (e.g., boolean or integer numbers) to the string.

```
$messaging->setData([
    "ClassificacaoGinasticaOlimpica" => [
        "Sanne Wevers",
        "Laurie Hernandez",
        "Simone Biles",
        "Marine Boyer",
        "Flávia Saraiva"
    ]
]);
```

Configuring Your Notification
-----------------------------

[](#configuring-your-notification)

### Set the title of the notification

[](#set-the-title-of-the-notification)

Indicates the title of the notification. This field is not visible in mobile phones and iOS tablets, only the iWatch.

Required Android; Optional iOS

```
$notification->setTitle("My Title");
```

### Set the message notification

[](#set-the-message-notification)

Indicates the body text of the notification.

Optional for Android and iOS

```
$notification->setBody("My Message");
```

### Set the icon in the notification

[](#set-the-icon-in-the-notification)

Indicates the icon in the notification.

It works only on Android (Opcional). The icon should is in res/drawable

```
$notification->setIcon("custom_icon_notification");
```

### Set the sound notification

[](#set-the-sound-notification)

It indicates a sound to play when the device receives a notification. Compatible with default or file name of a sound feature bundled in the application.

Android sound files should reside in / res / raw / iOS and sound files may be in the main package client application or the Library / Sounds folder application data container. See the developer's library iOS for more information.

Optional for Android and iOS

```
$notification->setSound("sound_notification");
```

### Set Tag

[](#set-tag)

It indicates whether each notification results in a new entry in the Android notifications tray. If not set, each request will create a new notification. If set and a notification with the same tag is already displayed, the new notice will replace the existing notification in the notifications drawer.

Only for Android (Optional)

```
$notification->setTag("notification_id_1");
```

### Set the icon color

[](#set-the-icon-color)

Indicates the color of the icon expressed in #rrggbb format.

Only for Android (Optional)

```
$notification->setColor("#FF0000");
```

### Associate an action for when the user clicks the notification

[](#associate-an-action-for-when-the-user-clicks-the-notification)

Indicates the action associated with a user click on the notification.

If set on iOS, it matches the category in the payload of APNs.

On Android, if this parameter is set, an activity with a corresponding intent filter is initiated when the user clicks the notification.

Optional for Android and iOS

```
$notification->setClickAction("OPEN_ACTIVITY_NOTIFICATION");
```

**Soon support for XMPP**

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~14 days

Total

2

Last Release

3589d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12245226?v=4)[Valdeir S.](/maintainers/valdeirpsr)[@valdeirpsr](https://github.com/valdeirpsr)

---

Top Contributors

[![valdeirpsr](https://avatars.githubusercontent.com/u/12245226?v=4)](https://github.com/valdeirpsr "valdeirpsr (5 commits)")[![valdeir2000](https://avatars.githubusercontent.com/u/606481?v=4)](https://github.com/valdeir2000 "valdeir2000 (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

notificationfirebaseandroidiosGoogle Cloud Messagevaldeir

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/valdeirpsr-firebasemessaging-php/health.svg)

```
[![Health](https://phpackages.com/badges/valdeirpsr-firebasemessaging-php/health.svg)](https://phpackages.com/packages/valdeirpsr-firebasemessaging-php)
```

###  Alternatives

[paragraph1/php-fcm

PHP application server for google firebase cloud messaging (FCM)

1961.3M11](/packages/paragraph1-php-fcm)[redjanym/php-firebase-cloud-messaging

PHP SDK for Firebase Cloud Messaging from Google

37858.2k2](/packages/redjanym-php-firebase-cloud-messaging)[redjanym/fcm-bundle

A Symfony Bundle for projects to send notifications in mobile devices through Firebase Cloud Messaging HTTP V1 API

43455.6k](/packages/redjanym-fcm-bundle)[leonardoteixeira/pushover

A simple PHP library for the Pushover service

1627.8k3](/packages/leonardoteixeira-pushover)[kedniko/firebase-cloud-messaging-http-v1-php

Firebase cloud messaging http v1 php

125.5k](/packages/kedniko-firebase-cloud-messaging-http-v1-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
