PHP code example of notify-eu / notify-bundle
1. Go to this page and download the library: Download notify-eu/notify-bundle 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/ */
notify-eu / notify-bundle example snippets
// .env
...
NOTIFY_CLIENT_ID=
NOTIFY_SECRET=
NOTIFY_TRANSPORT=
NOTIFY_URL=
],
...
php
namespace App\Controller;
use NotifyEu\NotifyBundle\Entity\NotifyMessage;
use NotifyEu\NotifyBundle\Service\NotifyService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class IndexController extends AbstractController
{
protected $notifyService;
public function __construct(NotifyService $notifyService)
{
$this->notifyService = $notifyService;
}
/**
* @Route("/notify", name="app_notify")
* @return Response
*/
public function index()
{
$message = (new NotifyMessage())
->setNotificationType('resetPassword')
->addRecipient('John Doe','[email protected] ')
->setLanguage('nl')
->setParams(['username' => 'John Doe']);
$response = $this->notifyService->send($message);
if ($response['success'] == true) {
return new Response('Notification send!');
}
}
}
php
$message->addRecipient('John Doe','[email protected] ')