JoliNotif provides a NotifierFactory which creates the best supported
notifier according to your platform. You don't have to care if you're running
on Linux, Windows or Mac OS:
use Joli\JoliNotif\NotifierFactory;
$notifier = NotifierFactory::create();The factory use the notifier's priority to determine the best notifier to use. For example some notifier has a low priority because they don't support some notification options. The best notifier will then be returned.
Note: The factory currently returns null if no notifier is supported on your system. Don't forget to add a check to avoid 'call to a member function of a non-object' error.
Create a notification is as simple as instantiating a Notification and
setting the option you want to use:
use Joli\JoliNotif\Notification;
$notification =
(new Notification())
->setBody('The notification body')
->setTitle('The notification title')
;As you can see, the notification provides a fluent API.
Now that you get your notification, just send it via the notifier:
$notifier->send($notification);And you're done!
Previous pages: