1. Go to this page and download the library: Download montopolis/mynabird 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/ */
montopolis / mynabird example snippets
// in config/mynabird.php
return [
'should_broadcast' => false,
];
declare(strict_types=1);
namespace App\Console;
use Montopolis\Mynabird\DataObjects\Alert;
use Montopolis\Mynabird\Interfaces\AlertsRepository;
class BroadcastAlert extends Command
{
protected $signature = 'app:broadcast-alert';
protected $description = 'Send an alert to all users.';
protected $alertsRepository;
public function __construct(AlertsRepository $alertsRepository)
{
parent::__construct();
$this->alertsRepository = $alertsRepository;
}
public function handle()
{
// Create an alert object: Montopolis\Mynabird\DataObjects\Alert
$alert = new Alert(
null,
$title,
$body,
$url,
$level,
null, // set to user ID for individual notification
true // set to `true` for broadcast message
);
// Send the alert:
$this->alertsRepository->store($alert);
}
}