PHPackages                             wildanmzaki/fcm - 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. wildanmzaki/fcm

ActiveLibrary

wildanmzaki/fcm
===============

This is helper class to simplify sending notification with firebase cloud messaging

1.0.2(1y ago)051MITPHP

Since Jun 6Pushed 1y ago1 watchersCompare

[ Source](https://github.com/WildanMZaki/fcm)[ Packagist](https://packagist.org/packages/wildanmzaki/fcm)[ RSS](/packages/wildanmzaki-fcm/feed)WikiDiscussions main Synced 1mo ago

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

WildanMZaki FCM Package
=======================

[](#wildanmzaki-fcm-package)

This package provides an easy way to send Firebase Cloud Messaging (FCM) notifications using Guzzle HTTP client.

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

[](#installation)

First, install the package via Composer:

```
composer require wildanmzaki/fcm
```

Usage
-----

[](#usage)

### Initialization

[](#initialization)

You need to provide the path to your Firebase service account credentials file and the project ID to initialize the `Client`.

```
use WildanMZaki\Fcm\Client;
use WildanMZaki\Fcm\Notification;

// Path to your Firebase service account credentials
$credentialsFilePath = storage_path('service-account.json');
$projectId = 'your-firebase-project-id';

// Initialize the client
$client = new Client($credentialsFilePath, $projectId);
```

### Sending a Notification to a Specific Device

[](#sending-a-notification-to-a-specific-device)

You can send a notification to a specific device by providing the device token.

```
// Create a notification
$notification = Notification::to('device-token')
    ->setTitle('Notification Title')
    ->setBody('Notification Body')
    ->setImage('https://example.com/image.png')
    ->setData(['key' => 'value']);

// Send the notification
$response = $client->send($notification);

// Print the response
print_r($response);
```

### Sending a Notification to a Topic

[](#sending-a-notification-to-a-topic)

You can send a notification to a topic by providing the topic name.

```
// Create a notification
$notification = Notification::topic('your-topic')
    ->setTitle('Notification Title')
    ->setBody('Notification Body')
    ->setImage('https://example.com/image.png')
    ->setData(['key' => 'value']);

// Send the notification
$response = $client->send($notification);

// Print the response
print_r($response);
```

Classes
-------

[](#classes)

### `WildanMZaki\Fcm\Client`

[](#wildanmzakifcmclient)

The `Client` class is responsible for sending notifications to the FCM API.

#### `__construct(string $credentialsFilePath, string $projectId, bool $isProduction = false)`

[](#__constructstring-credentialsfilepath-string-projectid-bool-isproduction--false)

- `$credentialsFilePath` - Path to the Firebase service account credentials file.
- `$projectId` - Your Firebase project ID.
- `$isProduction` - (Optional) If `true`, the client will be initialized for production use.

#### `send(Notification $notification)`

[](#sendnotification-notification)

- `notification` - An instance of the `Notification` class.
- Returns the response from the FCM API.

### `WildanMZaki\Fcm\Notification`

[](#wildanmzakifcmnotification)

The `Notification` class is used to build the notification payload.

#### `static to(string $token): self`

[](#static-tostring-token-self)

- `$token` - The device token to which the notification will be sent.
- Returns an instance of the `Notification` class.

#### `static topic(string $topic): self`

[](#static-topicstring-topic-self)

- `$topic` - The topic to which the notification will be sent.
- Returns an instance of the `Notification` class.

#### `setTitle(string $title): self`

[](#settitlestring-title-self)

- `$title` - The title of the notification.
- Returns the current instance of the `Notification` class.

#### `setBody(string $body): self`

[](#setbodystring-body-self)

- `$body` - The body of the notification.
- Returns the current instance of the `Notification` class.

#### `setImage(string $image): self`

[](#setimagestring-image-self)

- `$image` - The URL of the image to be included in the notification.
- Returns the current instance of the `Notification` class.

#### `setData(array $data): self`

[](#setdataarray-data-self)

- `$data` - An associative array of additional data to be included in the notification.
- Returns the current instance of the `Notification` class.

#### `build(): array`

[](#build-array)

- Builds the notification payload.
- Returns the notification payload as an array.

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

```

```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

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

Every ~13 days

Total

2

Last Release

691d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ce5c0ae28f2b7742ecf91289d30aecdc4ce56c7355730676bc57895a628d1bc0?d=identicon)[wildanmzaki](/maintainers/wildanmzaki)

---

Top Contributors

[![WildanMZaki](https://avatars.githubusercontent.com/u/106567925?v=4)](https://github.com/WildanMZaki "WildanMZaki (5 commits)")

### Embed Badge

![Health badge](/badges/wildanmzaki-fcm/health.svg)

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

###  Alternatives

[neuron-core/neuron-ai

The PHP Agentic Framework.

1.8k245.3k21](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1225.0k10](/packages/fleetbase-core-api)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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