1. Go to this page and download the library: Download fcorz/hyperf-firebase library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fcorz / hyperf-firebase example snippets
use Fcorz\Hyperf\Firebase\Facades\Firebase;
// Return an instance of the Messaging component for the default Firebase project
$defaultMessaging = Firebase::messaging();
// Return an instance of the Auth component for a specific Firebase project
$appMessaging = Firebase::project('app')->messaging();
$anotherAppMessaging = Firebase::project('another-app')->messaging();
// send message
$message = [
'token' => $deviceToken,
'notification' => [/* Notification data as array */], // optional
'data' => [/* data array */], // optional
];
Firebase::messaging()->send($message);
use Fcorz\Hyperf\Firebase\ApplicationProxy;
class yourProjectFirebase extends ApplicationProxy
{
protected string $name = 'project_name';
}
// send message
class yourClass
{
public function __construct(yourProjectFirebase $firebase)
{
$firebase->messaging()->send($message);
}
}