Skip to content

marcelglaeser/notification-bundle

 
 

Repository files navigation

mgilet/notification-bundle

A simple Symfony bundle to notify user

Latest Stable Version Latest Unstable Version Total Downloads License

SensioLabsInsight

mgilet/notificationBundle

Create and manage user notifications in an efficient way.

Symfony support :

  • 2.7.x
  • 2.8.x
  • 3.x

Bootstrap > 3.x highly recommended

Features

  • Easy notification management
  • Simple Twig render method
  • Pretty Twig template (dropdown using Bootstrap 3)
  • Fully customizable
  • Easy setup
  • No bloated dependencies (little requirements)

Notice: Only Doctrine ORM is supported for now.

Installation & usage

Installation

This bundle is available on packagist.

Notice : The bundle is actually in alpha state (no major issue encountered)

In order to install it, add the following line in your composer.json

// composer.json

...
"require": {
 "mgilet/notification-bundle": "dev-master",
},

Then perform a

$ composer install

This will install the latest commited version of the master branch.

When a stable version will come out you will just have to enter the following command:

$ composer require mgilet/notification-bundle

See documentation for next steps

Basic usage

class DefaultController extends Controller
{

    ...

    /**
     * @Route("/send-notification", name="send_notification")
     * @param Request $request
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
     */
    public function sendNotification(Request $request)
    {
        $manager = $this->get('mgilet.notification');
        $notif = $manager->generateNotification('Hello world !');
        $notif
         ->setMessage('This a notification.')
         ->setLink('http://symfony.com/');
        $manager->addNotification($this->getUser(), $notif);

        // or the one-line method :
        // $manager->createNotification($this->getUser(), 'Notification subject','Some random text','http://google.fr');

        return $this->redirectToRoute('homepage');
    }

See HERE for more

Translations

For now this bundle is only translated to de, en, es, fr, it.

Help me improve this by submitting your translations.

Community

You can help make this bundle better by contributing (every pull request will be considered) or submitting an issue.

Enjoy and share if you like it.

Licence

MIT

About

A simple Symfony bundle to notify user

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 77.5%
  • HTML 10.6%
  • JavaScript 9.3%
  • CSS 2.6%