Quickstart

Installing this package

This package is available on packagist, and can be installed with composer:

composer require edwinhoksberg/php-fcm

Configuring a Firebase account

This project uses Google Firebase for sending notifications, so we need to signup for a free account. A free account can store up to ~20 million messages, device groups and topics.

  1. Click here to go the firebase console page.
  2. Click on the Create Project button. Enter a project name and select your country/region.
  3. Once your project is created, click on continue to go to the project dashboard.
  4. Click on the gear icon in the top left, next to the Project Overview link, and click on Project Settings.
  5. Go to the Cloud Messaging tab.
  6. On this page, you should see several authentication tokens. Copy and save the Server key and Sender ID tokens somewhere. These will be used in the project configuration.

Configuring the project

When you instantiate a new Firebase Cloud Messaging object, pass the Server Key and Sender ID you retrieved from the previous steps:

<?php

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

$client = new \Fcm\FcmClient(/* Server Key */, /* Sender ID */);