yamad/laravel-fcm

Firebase Cloud Messaging API (V1) client for Laravel

Maintainers

Package info

github.com/yamader/laravel-fcm

pkg:composer/yamad/laravel-fcm

Transparency log

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-08-24 08:38 UTC

This package is auto-updated.

Last update: 2026-08-24 08:45:44 UTC


README

Firebase Cloud Messaging API (V1) client for Laravel 10-13.

Uses google/auth for OAuth 2.0 and Guzzle for HTTP.

Requirements

  • PHP ^8.1
  • Laravel ^10|^11|^12|^13

Installation

composer require yamad/laravel-fcm

The service provider and Fcm facade alias are discovered automatically.

Publish the config file:

php artisan vendor:publish --tag=fcm-config
# .env
FCM_PROJECT_ID=your-firebase-project-id
FCM_CREDENTIALS=/absolute/path/to/service-account.json   # optional

FCM_CREDENTIALS を未設定にすると Application Default Credentials(GOOGLE_APPLICATION_CREDENTIALS 環境変数や GCE/GKE のメタデータ)にフォールバックします。

Usage

use YamaD\LaravelFcm\Facades\Fcm;

// Send to a device registration token
$response = Fcm::send([
    'token' => $deviceToken,
    'notification' => [
        'title' => 'Hello',
        'body' => 'World',
    ],
]);

echo $response['name']; // projects/{project_id}/messages/{message_id}

// Send to a topic
Fcm::send([
    'topic' => 'news',
    'notification' => ['title' => 'Breaking news'],
]);

// Dry run (validation only, no delivery)
Fcm::send($message, validateOnly: true);

DI injection also works:

use YamaD\LaravelFcm\FcmClient;

public function handle(FcmClient $fcm)
{
    $fcm->send([...]);
}

The $message payload is passed to the FCM v1 API as-is. See the official reference for available fields.

Errors: HTTP 4xx/5xx throws GuzzleHttp\Exception\RequestException (the response is attached).

Testing

composer install
vendor/bin/phpunit