1. Go to this page and download the library: Download fei/notification-common 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/ */
fei / notification-common example snippets
use Fei\Service\Notification\Validator;
use Fei\Service\Notification\Entity;
$notificationData = [
'origin' => 'origin',
'recipient' => 'thomas',
'event' => 'chat.message.new',
'message' => 'Example message',
'type' => 1,
];
$notification = new Notification();
$notificationValidator = new NotificationValidator();
$notificationHydrator = new NotificationHydrator();
$notification = $notificationHydrator->hydrate($notificationData, $notification);
//validate returns true if your Notification instance is valid, or false in the other case
$isValid = $notificationValidator->validate($notification);
//getErrors() allows you to get an array of errors if there are some, or an empty array in the other case
$errors = $notificationValidator->getErrors();
use Fei\Service\Notification\Entity\Alert\Email;
use Fei\Service\Notification\Entity\Notification;
use Fei\Service\Notification\Entity\Alert\Android\Message as AndroidMessage;
use Fei\Service\Notification\Entity\Alert\Sms\Message as SmsMessage;
$notification = (new Notification())
->setMessage('Last test')
->setOrigin('test')
->setEvent('My best event')
->setType(Notification::TYPE_INFO)
->setAction(json_encode(['my.action' => 'first create']))
->setRecipient('user');
$alert_email = (new Email())
->setNotification($notification)
->setSubject('Email Subject')
->setContent('Email content')
->setEmail('[email protected]');
$alert_android = (new Android())
->setNotification($notification)
->setMessage(new AndroidMessage())
->setRecipients(['id_device_1', 'id_device_2'])
->setDryRun(true)
->setPushNotification(['title' => 'Notif', 'body' => 'Test message']);
$alert_sms = (new Sms())
->setNotification($notification)
->setMessage(new SmsMessage())
->setFrom('[email protected]')
->setRecipients(['[email protected]', '[email protected]'])
->setContent("Sms de test");
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.