1. Go to this page and download the library: Download drewlabs/envoyer 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/ */
drewlabs / envoyer example snippets
// Create a notification class
// Mail.php
use Drewlabs\Envoyer\Contracts\AttachmentsAware;
use Drewlabs\Envoyer\Contracts\NotificationInterface;
use SplFileInfo;
/** @package Drewlabs\Notifications\Tests\Stubs */
class Mail implements NotificationInterface, AttachmentsAware
{
public function setAttachments($attachments = [])
{
}
public function getAttachments()
{
return [
new SplFileInfo(__DIR__ . '/../contents/bordereau.pdf'),
];
}
public function getCc()
{
return null;
}
public function getSubject()
{
return "Successful registration";
}
public function getSender()
{
return new Address;
}
public function getReceiver()
{
return "[email protected]";
}
public function getContent()
{
return "<p>Hey Azandrew! Thank you for your registration</p>";
}
}
// defines a test driver to use
DriverRegistryFacade::defineDriver('test', static function () {
return new TestDriver();
});
// Send notification using command interface
$result = $command->driver('test')->send(new Mail);
use Drewlabs\Envoyer\Contracts\ClientInterface;
use Drewlabs\Envoyer\Contracts\NotificationInterface;
use Drewlabs\Envoyer\Contracts\NotificationResult;
use RuntimeException;
class TestDriver implements ClientInterface
{
public function __construct()
{
}
public function sendRequest(NotificationInterface $instance): NotificationResult
{
// TODO : Provide send request implementation logic
}
}
// Start building the mail
$mail = \Drewlabs\Envoyer\Mail::new()
->from('...', '...')
->to('...')
->bCc('...')
->subject('...')
->attach(new SplFileInfo(__DIR__ . '/...'))
->content(
// Create a messageable class
$message = Messageable::new()
->from('...')
->to('...')
->content("...");
// Use
use Drewlabs\Notifications\Command;
use Drewlabs\Notifications\Drivers;
$result = Command::driver(Drivers::AWS_SES)->send(/* ... */);
use Drewlabs\Envoyer\DriverRegistryFacade;
DriverRegistryFacade::defineDriver('test', static function () {
return new TestProvider();
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.