PHPackages                             irice/yii2-fcm-manager - 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. irice/yii2-fcm-manager

ActiveYii2-extension[Mail &amp; Notifications](/categories/mail)

irice/yii2-fcm-manager
======================

FCM Notification manager for Yii2

0.2.1(6y ago)1309MITPHP

Since Oct 21Pushed 6y ago1 watchersCompare

[ Source](https://github.com/iridance/yii2-fcm-manager)[ Packagist](https://packagist.org/packages/irice/yii2-fcm-manager)[ RSS](/packages/irice-yii2-fcm-manager/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (13)Versions (2)Used By (0)

FCM Manager for Yii2
====================

[](#fcm-manager-for-yii2)

Installation
------------

[](#installation)

### Composer Install

[](#composer-install)

```
composer require irice/yii2-fcm-manager

```

Database Migration
------------------

[](#database-migration)

### cofnig/console.php

[](#cofnigconsolephp)

```
return [
    'controllerMap' => [
        'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationPath' => null,
            'migrationNamespaces' => [
                'fcm\manager\migrations',
                ...
            ],
        ],
    ],
    ...
];
```

And run migrate command

```
php yii migrate

```

Configuration
-------------

[](#configuration)

### config/web.php

[](#configwebphp)

```
return [
    'modules' => [
        'fcm' => [
            'class' => 'fcm\manager\Module',
            ...
        ],
        ...
    ],
    ...
    'components' => [
        'fcm' => [
            'class' => 'fcm\manager\components\Connection',
            // you can download config file on firebase console 'https://console.firebase.google.com/u/1/project//settings/serviceaccounts/adminsdk'
            'configPath' => __DIR__ . '/-firebase-adminsdk.json',
        ],
        ...
    ],
    ...
];
```

Basic Usage
-----------

[](#basic-usage)

### Register device to database

[](#register-device-to-database)

```
$result = Yii::$app->fcm->deviceRegisterClass::registerDevice(
    '', // or ['', '']
     // user identity id
);
```

### Subscribe device to Topic

[](#subscribe-device-to-topic)

```
$result = Yii::$app->fcm->subscribeToTopic(
    '',
    '' // or ['', '']
);
```

### Unsubscribe device from Topic

[](#unsubscribe-device-from-topic)

```
$result = Yii::$app->fcm->unSubscribeFromTopic(
    '',
    '' // or ['', '']
);
```

### Send message to Topic

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

```
$result = Yii::$app->fcm->sendToTopic(
    '',
    '',
    '',
    '' // optional
);
```

### Send message to Device

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

```
$result = Yii::$app->fcm->sendToTokens(
    '' // or ['', '']
    '',
    '',
    '' // optional
);
```

Schedule Send Message
---------------------

[](#schedule-send-message)

The feature implement by Yii2-queue extension.

### config/console.php (config/web.php)

[](#configconsolephp-configwebphp)

```
'components' => [
    'queue' => [
        'class' => 'yii\queue\db\Queue',
        'serializer' => 'fcm\manager\components\PhpSerializer',
        'deleteReleased' => false,
        'as log' => 'yii\queue\LogBehavior',
    ],
    'mutex' => [
        'class' => 'yii\mutex\PgsqlMutex',
    ],
    'fcm' => [
        'class' => 'fcm\manager\components\Connection',
        'configPath' => __DIR__ . '/-firebase-adminsdk.json',
    ],
    ...
]
```

### Schedule a message to Topic

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

```
$job = new \fcm\manager\jobs\SendJob([
    'notification' => [
        'title' => '',
        'body' => '',
        'target' => [
            'type' => \fcm\manager\jobs\SendJob::TYPE_TOPIC,
            'value' => '',
        ],
    ],
]);

$delayTime = strtotime('2019-12-31 00:00:00') - time(); //Send message on specified time.
//$delayTime = strtotime('next Saturday') - time(); //Send message on next weekend.
//$delayTime = 60 * 60 * 24; //Send message after 24 hours.

$queueId = Yii::$app->queue->delay($delayTime)->push($job);
```

#### Auto update fcm progress after send

[](#auto-update-fcm-progress-after-send)

Implement NotificationInterface on custom class

```
class Notification extends \yii\db\ActiveRecord implements \fcm\manager\models\NotificationInterface
{
    ...
    public function getSuccessStatus()
    {
        return static::STATUS['SENDED'];
    }

    public function getFailStatus()
    {
        return static::STATUS['FAILED'];
    }

    public function updateStatus($value)
    {
        $this->status = $value;
        return $this->save();
    }
}
```

TODO
----

[](#todo)

### Notification GUI Manager

[](#notification-gui-manager)

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

[](#requirements)

Yii2-queue

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

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

2396d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/69b608dc39b26ddb292493c80af8b88985d1886073c06a6e25a269b33fb48a18?d=identicon)[iridance](/maintainers/iridance)

---

Top Contributors

[![iridance](https://avatars.githubusercontent.com/u/9459560?v=4)](https://github.com/iridance "iridance (22 commits)")

---

Tags

managerfirebaseFCMyii2

### Embed Badge

![Health badge](/badges/irice-yii2-fcm-manager/health.svg)

```
[![Health](https://phpackages.com/badges/irice-yii2-fcm-manager/health.svg)](https://phpackages.com/packages/irice-yii2-fcm-manager)
```

###  Alternatives

[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)[redjanym/php-firebase-cloud-messaging

PHP SDK for Firebase Cloud Messaging from Google

39847.9k1](/packages/redjanym-php-firebase-cloud-messaging)[aksafan/yii2-fcm-both-api

Yii2 Extension for sending push notification with both Firebase Cloud Messaging (FCM) HTTP Server Protocols (APIs).

1552.4k1](/packages/aksafan-yii2-fcm-both-api)

PHPackages © 2026

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