PHPackages                             aweiand/larafirebase - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. aweiand/larafirebase

ActiveLibrary[HTTP &amp; Networking](/categories/http)

aweiand/larafirebase
====================

Laravel Firebase Cloud Messaging.

04PHP

Since Mar 27Pushed 1y agoCompare

[ Source](https://github.com/aweiand/larafirebase)[ Packagist](https://packagist.org/packages/aweiand/larafirebase)[ RSS](/packages/aweiand-larafirebase/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

### Introduction

[](#introduction)

**Larafirebase** is a package thats offers you to send push notifications or custom messages via Firebase in Laravel.

Firebase Cloud Messaging (FCM) is a cross-platform messaging solution that lets you reliably deliver messages at no cost.

For use cases such as instant messaging, a message can transfer a payload of up to 4KB to a client app.

### Installation

[](#installation)

Follow the steps below to install the package.

**Composer**

```
composer require aweiand/larafirebase

```

**Copy Config**

Run `php artisan vendor:publish --provider="Aweiand\Larafirebase\Providers\LarafirebaseServiceProvider"` to publish the `larafirebase.php` config file.

**Get Athentication Key**

Get Authentication Key from

**Configure larafirebase.php as needed**

```
'firebase_credentials_file' => '{PATH_TO_THE_CREDENTIALS_FILE}',
'firebase_project_id' =>       '{FIREBASE_PROJECT_ID}'

```

### Usage

[](#usage)

Follow the steps below to find how to use the package.

Example usage in **Controller/Service** or any class:

```
use Aweiand\Larafirebase\Facades\Larafirebase;

class MyController
{
    private $deviceTokens ='{TOKEN_1}';

    public function sendNotification()
    {
        return Larafirebase::withTitle('Test Title')
            ->withBody('Test body')
            ->withImage('https://firebase.google.com/images/social.png')
            ->withIcon('https://seeklogo.com/images/F/firebase-logo-402F407EE0-seeklogo.com.png')
            ->withSound('default')
            ->withClickAction('https://www.google.com')
            ->withPriority('high')
            ->withAdditionalData([
                'color' => '#rrggbb',
                'badge' => 0,
            ])
            ->sendNotification($this->deviceTokens);

        // Or
        return Larafirebase::fromArray(['title' => 'Test Title', 'body' => 'Test body'])->sendNotification($this->deviceTokens);
    }

    public function sendMessage()
    {
        return Larafirebase::withTitle('Test Title')
            ->withBody('Test body')
            ->sendMessage($this->deviceTokens);

        // Or
        return Larafirebase::fromArray(['title' => 'Test Title', 'body' => 'Test body'])->sendMessage($this->deviceTokens);
    }
}
```

Example usage in **Notification** class:

```
use Illuminate\Notifications\Notification;
use Aweiand\Larafirebase\Messages\FirebaseMessage;

class SendBirthdayReminder extends Notification
{
    /**
     * Get the notification's delivery channels.
     */
    public function via($notifiable)
    {
        return ['firebase'];
    }

    /**
     * Get the firebase representation of the notification.
     */
    public function toFirebase($notifiable)
    {
        $deviceTokens = [
            '{TOKEN_1}',
            '{TOKEN_2}'
        ];

        return (new FirebaseMessage)
            ->withTitle('Hey, ', $notifiable->first_name)
            ->withBody('Happy Birthday!')
            ->asNotification($deviceTokens); // OR ->asMessage($deviceTokens);
    }
}
```

### Tips

[](#tips)

- Check example how to receive messages or push notifications in a [JavaScript client](/javascript-client).
- You can use `larafirebase()` helper instead of Facade.

### Payload

[](#payload)

Check how is formed payload to send to firebase:

Example 1:

```
Larafirebase::withTitle('Test Title')->withBody('Test body')->sendNotification('token1');
```

```
{
  "registration_ids": [
    "token1"
  ],
  "notification": {
    "title": "Test Title",
    "body": "Test body"
  },
  "priority": "normal"
}
```

Example 2:

```
Larafirebase::withTitle('Test Title')->withBody('Test body')->sendMessage('token1');
```

```
{
  "registration_ids": [
    "token1"
  ],
  "data": {
    "title": "Test Title",
    "body": "Test body"
  }
}
```

If you want to create payload from scratch you can use method `fromRaw`, for example:

```
return Larafirebase::fromRaw([
    'registration_ids' => ['token1', 'token2'],
    'data' => [
        'key_1' => 'Value 1',
        'key_2' => 'Value 2'
    ],
    'android' => [
        'ttl' => '1000s',
        'priority' => 'normal',
        'notification' => [
            'key_1' => 'Value 1',
            'key_2' => 'Value 2'
        ],
    ],
])->send();
```

---

Made with ♥ by Augusto Weiand ([@aweiand](https://github.com/aweiand)).

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/0c288a88465f86c833167397de5feeb2f620f9f9b09d2e8d71a3544f7f06631b?d=identicon)[aweiand](/maintainers/aweiand)

---

Top Contributors

[![gentritabazi](https://avatars.githubusercontent.com/u/35135482?v=4)](https://github.com/gentritabazi "gentritabazi (72 commits)")[![muhamedRadwan](https://avatars.githubusercontent.com/u/16479089?v=4)](https://github.com/muhamedRadwan "muhamedRadwan (5 commits)")[![aweiand](https://avatars.githubusercontent.com/u/1443817?v=4)](https://github.com/aweiand "aweiand (4 commits)")[![ferasbbm](https://avatars.githubusercontent.com/u/49439225?v=4)](https://github.com/ferasbbm "ferasbbm (3 commits)")[![astritzeqiri](https://avatars.githubusercontent.com/u/8720176?v=4)](https://github.com/astritzeqiri "astritzeqiri (3 commits)")[![eiabea](https://avatars.githubusercontent.com/u/688128?v=4)](https://github.com/eiabea "eiabea (3 commits)")[![samushi](https://avatars.githubusercontent.com/u/3842345?v=4)](https://github.com/samushi "samushi (2 commits)")[![HarmJan1990](https://avatars.githubusercontent.com/u/22013950?v=4)](https://github.com/HarmJan1990 "HarmJan1990 (2 commits)")[![alchalade](https://avatars.githubusercontent.com/u/9267638?v=4)](https://github.com/alchalade "alchalade (1 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (1 commits)")[![anggerpputro](https://avatars.githubusercontent.com/u/21016176?v=4)](https://github.com/anggerpputro "anggerpputro (1 commits)")[![nathangaskin](https://avatars.githubusercontent.com/u/6713866?v=4)](https://github.com/nathangaskin "nathangaskin (1 commits)")[![oriceon](https://avatars.githubusercontent.com/u/358823?v=4)](https://github.com/oriceon "oriceon (1 commits)")[![codebeauty](https://avatars.githubusercontent.com/u/596842?v=4)](https://github.com/codebeauty "codebeauty (1 commits)")

### Embed Badge

![Health badge](/badges/aweiand-larafirebase/health.svg)

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

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