PHPackages                             redjanym/php-firebase-cloud-messaging - 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. redjanym/php-firebase-cloud-messaging

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

redjanym/php-firebase-cloud-messaging
=====================================

PHP SDK for Firebase Cloud Messaging from Google

2.1.1(3mo ago)37864.6k↓39.1%191MITPHPPHP &gt;=7.4CI passing

Since Feb 25Pushed 3mo ago3 watchersCompare

[ Source](https://github.com/redjanym/php-firebase-cloud-messaging)[ Packagist](https://packagist.org/packages/redjanym/php-firebase-cloud-messaging)[ Docs](https://github.com/redjanym/php-firebase-cloud-messaging)[ RSS](/packages/redjanym-php-firebase-cloud-messaging/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (6)Versions (19)Used By (1)

PHP Firebase Cloud Messaging
============================

[](#php-firebase-cloud-messaging)

[![Buy Me a Coffee at ko-fi.com](https://camo.githubusercontent.com/7d01e38e117b1a334d2c3459e0155336f76931a16a4180dab87fde963df72a57/68747470733a2f2f617a3734333730322e766f2e6d7365636e642e6e65742f63646e2f6b6f6669322e706e673f763d30)](https://www.paypal.me/ymerajredjan)

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

See the official Firebase docs:

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- A Firebase service account JSON file ([how to generate one](https://firebase.google.com/docs/admin/setup#initialize_the_sdk_in_non-google_environments))

Setup
-----

[](#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.*"
}
```

Usage
-----

[](#usage)

### Send a Message to a Device

[](#send-a-message-to-a-device)

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

$serviceAccountPath = '/path/to/service-account.json';

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

$response = $client->send($notification);
```

### Send a Message to a Topic

[](#send-a-message-to-a-topic)

```
use RedjanYm\FCM\Client;
use RedjanYm\FCM\Notification;
use RedjanYm\FCM\Recipient\Topic;

$serviceAccountPath = '/path/to/service-account.json';

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

$response = $client->send($notification);
```

Clients subscribe to topics from the client app. See the [Firebase topic documentation](https://firebase.google.com/docs/cloud-messaging/android/topic-messaging) for details on managing topic subscriptions.

### Customizing Notifications

[](#customizing-notifications)

The `Notification` object exposes public properties for platform-specific configuration:

```
$notification = new Notification($recipient, 'Title', 'Body');

// Android
$notification->androidPriority = 'high';
$notification->androidChannelId = 'my_channel';
$notification->icon = 'ic_notification';
$notification->color = '#FF0000';

// APNs (iOS)
$notification->apnsPriority = '10';
$notification->badge = 5;
$notification->sound = 'default';
$notification->contentAvailable = true;

// General
$notification->image = 'https://example.com/image.png';
$notification->ttl = '3600s';
$notification->clickAction = 'OPEN_ACTIVITY';
$notification->analyticsLabel = 'campaign_123';

// Additional platform-specific settings via extra arrays
$notification->extraNotificationSettings = ['tag' => 'my-tag'];
$notification->extraAPNSHeadersSettings = ['apns-collapse-id' => 'campaign'];
$notification->webPushHeadersSettings = ['Urgency' => 'high'];
```

Testing
-------

[](#testing)

Install dev dependencies and run the test suite with PHPUnit:

```
composer install
vendor/bin/phpunit
```

To run a specific test file:

```
vendor/bin/phpunit tests/NotificationTest.php
```

To run a specific test method:

```
vendor/bin/phpunit --filter testJsonSerializeWithTopic
```

Migrating from V1
-----------------

[](#migrating-from-v1)

V2 of this package introduces breaking changes due to the migration from the legacy FCM API to the HTTP V1 API. The new structure is still simple and very similar to the previous one.

Interpreting Responses
----------------------

[](#interpreting-responses)

The `send()` method returns a PSR-7 `ResponseInterface`. Responses follow the standard FCM specifications:

- [Downstream message responses](https://firebase.google.com/docs/cloud-messaging/http-server-ref#interpret-downstream)
- [Error codes](https://firebase.google.com/docs/cloud-messaging/http-server-ref#error-codes)

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community23

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 71.4% 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 ~255 days

Recently: every ~108 days

Total

14

Last Release

90d ago

Major Versions

v1.1.7 → v2.0.02025-01-27

PHP version history (2 changes)v1.0PHP &gt;=5.5

v2.0.0PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/07a32e6587acf1bc5a3fa4e2be10d791f9b85987136d11a17db5420928793dce?d=identicon)[redjanym](/maintainers/redjanym)

---

Top Contributors

[![redjanym](https://avatars.githubusercontent.com/u/15679866?v=4)](https://github.com/redjanym "redjanym (40 commits)")[![sngrl](https://avatars.githubusercontent.com/u/6196684?v=4)](https://github.com/sngrl "sngrl (10 commits)")[![NelinD](https://avatars.githubusercontent.com/u/10078264?v=4)](https://github.com/NelinD "NelinD (2 commits)")[![amvardo](https://avatars.githubusercontent.com/u/22379671?v=4)](https://github.com/amvardo "amvardo (1 commits)")[![kmarques](https://avatars.githubusercontent.com/u/7290607?v=4)](https://github.com/kmarques "kmarques (1 commits)")[![buryni](https://avatars.githubusercontent.com/u/172052?v=4)](https://github.com/buryni "buryni (1 commits)")[![johann59](https://avatars.githubusercontent.com/u/9280133?v=4)](https://github.com/johann59 "johann59 (1 commits)")

---

Tags

androidfcmgoogle-firebasehacktoberfestiosnotificationsphpcloudgooglenotificationsfirebaseFCMandroidios

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/redjanym-php-firebase-cloud-messaging/health.svg)

```
[![Health](https://phpackages.com/badges/redjanym-php-firebase-cloud-messaging/health.svg)](https://phpackages.com/packages/redjanym-php-firebase-cloud-messaging)
```

###  Alternatives

[paragraph1/php-fcm

PHP application server for google firebase cloud messaging (FCM)

1991.3M11](/packages/paragraph1-php-fcm)[redjanym/fcm-bundle

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

43457.4k](/packages/redjanym-fcm-bundle)[kedniko/firebase-cloud-messaging-http-v1-php

Firebase cloud messaging http v1 php

126.0k](/packages/kedniko-firebase-cloud-messaging-http-v1-php)[edwinhoksberg/php-fcm

A library for sending Firebase cloud messages and managing user topic subscriptions, device groups and devices.

68356.4k1](/packages/edwinhoksberg-php-fcm)[coder966/fcm-simple

PHP library for Firebase Cloud Messaging

141.2k](/packages/coder966-fcm-simple)[vyconsulting-group/push-notification

PHP wrapper FCM

154.4k](/packages/vyconsulting-group-push-notification)

PHPackages © 2026

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