PHP code example of phant / notifier

1. Go to this page and download the library: Download phant/notifier 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/ */

    

phant / notifier example snippets


use Phant\Notifier\Service\Handler as NotifierHandler;
use Phant\Notifier\Entity\Notification\Action as NotificationAction;
use Phant\Notifier\Entity\Notification\Type as NotificationType;
use Phant\Notifier\Factory\Notification as NotificationFactory;
use Phant\Notifier\Factory\Notification\Content as NotificationContentFactory;
use Phant\Notifier\Entity\Transport\Channel;
use Phant\Notifier\Entity\Transport\Collection as NotifierTransportCollection;
use Phant\Notifier\Entity\Transport\Email as NotifierTransportEmail;
use App\EmailBuilder;
use App\EmailSender;

$notifierHandler = new NotifierHandler(
	(new NotifierTransportCollection())
		->add(
			new NotifierTransportEmail(
				new EmailBuilder(),
				new EmailSender(),
				'[email protected]',
				'Best app'
			)
		)
);

$notifierHandler->dispatch(
	NotificationFactory::make(
		NotificationType::Information,
		NotificationContentFactory::make(
			'Hello world!',
			'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
			[
				'Foo' => 'Bar'
			]
		),
		new NotificationAction(
			'https://domain.ext/path',
			'Action'
		),
		'[email protected]'
		Channel::Email
	)
);