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

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

andimariadi/php-firebase-cloud-messaging
========================================

PHP API for Firebase Cloud Messaging from Google

v1.0.0(1y ago)026MITPHPPHP &gt;=5.5

Since Oct 25Pushed 1y agoCompare

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

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

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

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

PHP API for Firebase Cloud Messaging from Google.

Currently this app server library only supports sending Messages/Notifications via HTTP.

See original Firebase docs:

Migrate from legacy FCM APIs to HTTP v1
=======================================

[](#migrate-from-legacy-fcm-apis-to-http-v1)

See original Firebase Migrate:

- Update the server endpoint

```
POST https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send

```

Setup
=====

[](#setup)

Install via Composer:

```
composer require andimariadi/php-firebase-cloud-messaging

```

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

```
"require": {
    "andimariadi/php-firebase-cloud-messaging": "1.*"
}

```

Send message to **one or multiple** Devices
===========================================

[](#send-message-to-one-or-multiple-devices)

```
use sngrl\PhpFirebaseCloudMessaging\Client;
use sngrl\PhpFirebaseCloudMessaging\Message;
use sngrl\PhpFirebaseCloudMessaging\Recipient\Device;
use sngrl\PhpFirebaseCloudMessaging\Notification;

$server_key = '_YOUR_SERVER_KEY_';
$server_url = 'https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send';
$client = new Client();
$client->setApiKey($server_key);
$client->setProxyApiUrl($server_url);
$message = new Message();
$message->addRecipient(new Device('_YOUR_DEVICE_TOKEN_'));
$message
    ->setNotification(new Notification('some title', 'some body'))
    ->setData(['key' => 'value'])
;

$response = $client->send($message);
var_dump($response->getStatusCode());
var_dump($response->getBody()->getContents());

```

Send message to Topic
=====================

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

Currently sending to topics only supports a single topic as recipient. Mutliple topic as outlined in the google docs don't seem to work, yet.

```
use sngrl\PhpFirebaseCloudMessaging\Client;
use sngrl\PhpFirebaseCloudMessaging\Message;
use sngrl\PhpFirebaseCloudMessaging\Recipient\Topic;
use sngrl\PhpFirebaseCloudMessaging\Notification;

$server_key = '_YOUR_SERVER_KEY_';
$server_url = 'https://fcm.googleapis.com/v1/projects/{PROJECT_ID}/messages:send';
$client = new Client();
$client->setApiKey($server_key);
$client->setProxyApiUrl($server_url);

$message = new Message();
$message->addRecipient(new Topic('_YOUR_TOPIC_'));
$message
    ->setNotification(new Notification('some title', 'some body'))
    ->setData(['key' => 'value'])
;

$response = $client->send($message);
var_dump($response->getStatusCode());
var_dump($response->getBody()->getContents());

```

Subscribe user to the topic
===========================

[](#subscribe-user-to-the-topic)

```
use sngrl\PhpFirebaseCloudMessaging\Client;

$server_key = '_YOUR_SERVER_KEY_';
$client = new Client();
$client->setApiKey($server_key);

$response = $client->addTopicSubscription('_SOME_TOPIC_ID_', ['_FIRST_TOKEN_', '_SECOND_TOKEN_']);
var_dump($response->getStatusCode());
var_dump($response->getBody()->getContents());

```

Remove user subscription to the topic
=====================================

[](#remove-user-subscription-to-the-topic)

```
use sngrl\PhpFirebaseCloudMessaging\Client;

$server_key = '_YOUR_SERVER_KEY_';
$client = new Client();
$client->setApiKey($server_key);

$response = $client->removeTopicSubscription('_SOME_TOPIC_ID_', ['_FIRST_TOKEN_', '_SECOND_TOKEN_']);
var_dump($response->getStatusCode());
var_dump($response->getBody()->getContents());

```

Interpreting responses
======================

[](#interpreting-responses)

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

-
-

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

 Bus Factor1

Top contributor holds 58.1% 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

Unknown

Total

1

Last Release

561d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/184ea06ef8c1f0d55dabcd0d82f29e108f7e729fc0225aa1c230c66551d272ba?d=identicon)[andimariadi](/maintainers/andimariadi)

---

Top Contributors

[![redjanym](https://avatars.githubusercontent.com/u/15679866?v=4)](https://github.com/redjanym "redjanym (25 commits)")[![sngrl](https://avatars.githubusercontent.com/u/6196684?v=4)](https://github.com/sngrl "sngrl (10 commits)")[![andimariadi](https://avatars.githubusercontent.com/u/17026088?v=4)](https://github.com/andimariadi "andimariadi (2 commits)")[![NelinD](https://avatars.githubusercontent.com/u/10078264?v=4)](https://github.com/NelinD "NelinD (2 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)")[![amvardo](https://avatars.githubusercontent.com/u/22379671?v=4)](https://github.com/amvardo "amvardo (1 commits)")

---

Tags

phpcloudgooglenotificationsfirebaseFCMchromeandroidios

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[redjanym/fcm-bundle

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

43453.0k](/packages/redjanym-fcm-bundle)[redjanym/php-firebase-cloud-messaging

PHP SDK for Firebase Cloud Messaging from Google

39847.9k1](/packages/redjanym-php-firebase-cloud-messaging)[paragraph1/php-fcm

PHP application server for google firebase cloud messaging (FCM)

1991.2M10](/packages/paragraph1-php-fcm)[kedniko/firebase-cloud-messaging-http-v1-php

Firebase cloud messaging http v1 php

124.8k](/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.

68328.5k1](/packages/edwinhoksberg-php-fcm)[bentools/webpush-bundle

Send push notifications through Web Push Protocol to your Symfony users.

71274.3k](/packages/bentools-webpush-bundle)

PHPackages © 2026

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