notify-eu / notify-bundle
Notify bundle for Symfony
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.1
- guzzlehttp/guzzle: ^6.3
- symfony/framework-bundle: ^4.0
Requires (Dev)
- phpunit/phpunit: ^6
- symfony/phpunit-bridge: ^4.0
This package is auto-updated.
Last update: 2024-11-13 19:04:51 UTC
README
This package makes it easy to send notifications using Notify with Symfony 4
Contents
Installation
You can install the package via composer:
$ composer require notify-eu/notify-bundle
Setting up your Notify account
Add your Notify credentials to your .env
:
// .env ... NOTIFY_CLIENT_ID= NOTIFY_SECRET= NOTIFY_TRANSPORT= NOTIFY_URL= ], ...
NOTIFY_URL
is not mandatory. Can be used when you want to overwrite the endpoint Notify is calling. (f.e. different url for Staging/production)
Usage
- Load the 'notifyService' inside your services/controllers
- Create a NotifyMessage object with the required parameters
- Send the message
<?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','John.Doe@notify.eu') ->setLanguage('nl') ->setParams(['username' => 'John Doe']); $response = $this->notifyService->send($message); if ($response['success'] == true) { return new Response('Notification send!'); } } }
NotifyMessage
Make sure to add a recipient to the message:
$message->addRecipient('John Doe','John.Doe@notify.eu')
All available methods
notificationType('')
: Accepts a string value.addRecipient($array)
: Accepts an array of arrays of 'name'/'recipient' keystransport('')
: Accepts a string value. if not set, it will fallback to NOTIFY_TRANSPORT in .env filelanguage('')
: Accepts a string value.params($array)
: Accepts an array of key/value parametersCc($array)
: Accepts an array of arrays of 'name'/'recipient' keysBcc($array)
: Accepts an array of arrays of 'name'/'recipient' keys
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
$ composer test
Security
If you discover any security related issues, please email info@notify.eu instead of using the issue tracker.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.