edwinhoksberg / php-fcm
A library for sending Firebase cloud messages and managing user topic subscriptions, device groups and devices.
Installs: 222 441
Dependents: 3
Suggesters: 0
Security: 0
Stars: 68
Watchers: 5
Forks: 32
Open Issues: 18
Requires
- php: >= 7.2
- guzzlehttp/guzzle: ^6.3 || ^7.0
Requires (Dev)
- mockery/mockery: ^1.0
- php-coveralls/php-coveralls: ^2.3
- phpunit/phpunit: ^6.5
This package is auto-updated.
Last update: 2024-11-07 15:18:15 UTC
README
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:
composer test
Before the first time you run them, you may need to run:
composer install
Windows TESTING
For local Windows Testing, you will need to install xdebug and add
zend_extension=xdebug xdebug.mode=coverage
and set composer.json scripts line to:
"scripts": {
"test": ["vendor/bin/phpunit -c phpunit.dist.xml"]
},
xUX TESTING:
For local xUX or online github/codeforce testing, in composer.json set scripts line to:
"scripts": {
"test": ["XDEBUG_MODE=coverage vendor/bin/phpunit -c phpunit.dist.xml"]
},