PHP code example of meita / realtime-notifications
1. Go to this page and download the library: Download meita/realtime-notifications 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/ */
meita / realtime-notifications example snippets
use Meita\RealtimeNotifications\Facades\MeitaNotifications;
MeitaNotifications::push(42, 'Order created successfully', [
'title' => 'Orders',
'type' => 'success',
'keywords' => ['order', 'payments'],
'data' => ['order_id' => 999],
'format' => 'json', // or 'txt'
'ttl_seconds' => 3600,
]);
$token = MeitaNotifications::tokenForUser(42);
use Meita\RealtimeNotifications\Adapters\LocalFilesystemAdapter;
use Meita\RealtimeNotifications\MeitaNotificationsManager;
$config = [
'disk_root' => __DIR__.'/storage', // where files are stored
'base_dir' => 'meita/notifications',
'secret_key' => 'base64:your-key-or-plain-string',
'auth' => ['token_ttl_seconds' => 3600],
];
$manager = new MeitaNotificationsManager(
$config,
new LocalFilesystemAdapter($config['disk_root'])
);
// push
$ref = $manager->push('user-123', 'Hello standalone', ['keywords' => ['demo']]);
// token (sign/verify yourself in your HTTP layer)
$token = $manager->tokenForUser('user-123');
bash
php artisan vendor:publish --tag=meita-notifications-config
php artisan vendor:publish --tag=meita-notifications-assets --force
bash
php artisan vendor:publish --tag=meita-notifications-assets --force