Skip to content
A PHP library for sending Firebase Cloud Messages and managing user topic subscriptions, device groups and devices.
PHP
Branch: master
Clone or download

Latest commit

Latest commit d188969 Jan 27, 2020

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
src fix for addDataArray issue Jan 27, 2020
tests adding more tests Jan 27, 2020
.coveralls.yml Revert "Explicitly set the coveralls service name" Apr 9, 2018
.travis.yml Update .travis.yml Jun 7, 2019
LICENSE.md
README.md adding note on test Jan 27, 2020
composer.json
composer.lock Travis CI and coveralls integration Apr 9, 2018
phpunit.dist.xml

README.md

PHP-FCM Build Status Coverage Status Packagist Documentation

A PHP library for sending Firebase Cloud Messages and managing user topic subscriptions, device groups and devices.

Installation

Installation with composer:

composer require edwinhoksberg/php-fcm

Quickstart

<?php

// Load composer
require 'vendor/autoload.php';

// Instantiate the client with the project api_token and sender_id.
$client = new \Fcm\FcmClient($apiToken, $senderId);

// Instantiate the push notification request object.
$notification = new \Fcm\Push\Notification();

// Enhance the notification object with our custom options.
$notification
    ->addRecipient($deviceId)
    ->setTitle('Hello from php-fcm!')
    ->setBody('Notification body')
    ->addData('key', 'value');

// Send the notification to the Firebase servers for further handling.
$client->send($notification);

Full documentation

Read the documentation here or look in the docs directory.

Tests

Run the unit tests with PHPUnit:

vendor/bin/phpunit -c phpunit.dist.xml

Before the first time you run them, you may need to run:

composer install

License

MIT

You can’t perform that action at this time.