Download the PHP package namshi/notificator without Composer

On this page you can find all versions of the php package namshi/notificator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package notificator

NAMSHI | Notificator

Build Status

SensioLabsInsight

Notificator is a very simple and lightweight library to handle notifications the smart way.

It took inspiration from other libraries and patterns (Monolog and event dispatching) in order to provide a domain-driven lean notification library.

Concepts are very simple: you have a notification Manager which has a few handlers registered with it (maybe an Email handler, a Skype handler, etc.); you only have to create a notification class, define which handlers should handle it and trigger it through the manager.

It is way simpler in code than in words, check the documentation below!

Installation

Installation can be done via composer, as the library is already on packagist.

The library uses semantic versioning for its API, so it is recommended to use a stable minor version (1.0, 1.1, etc.) and stick to it when declaring dependencies through composer:

Usage

Using this library is very easy thanks to the simple concept - borrowed from others - behind it: you basically have a notification manager with some handlers and then you fire (trigger()) the notification with the manager. At that point, all the handlers that need to fire that notification will take care of firing it in their context (might be an email, a skype message, etc) and tell the manager that they're done, so that the manager can forward the notification to the next handler.

This code, ran on ubuntu, will fire the notification using the notify-send utility:

notify-send

The notification Manager

The manager is the entity that registers all the handlers and fires the notification.

You can set and add handlers very easily:

Creating a new notification

Creating new notifications is very easy, as they are plain PHP classes.

They might extend the base Notification class but that is not mandatory. It is recommended, to be able to fire one notification through multiple handlers, to extend the base Notification class, and implement different interfaces that will be later checked by the handlers.

As you probably got, the above notification class is meant to be triggered via email and with the echo function (pretty useless, but gives you an idea).

But the work wouldn't be over here, as you would need to implement handlers for this notification...

Creating a new handler

Let's say that we want to create the handlers that would handle the notification above, by echoing it and sending it via email: it is a matter of implementing 2 classes with a couple methods, shouldHandle and handle.

Let's see how the EchoedNotificationHandler should look like:

Pretty easy, right?

First, we need to check if this handler is handling the given notification, and that check is done by seeing if the notification implements a known interface; second, we actually trigger the notification.

The same thing needs to be done for the EmailNotificationHandler:

If you want to stop notification propagation after an handler has triggered the notification, you just need to return false in the handle method of the handler:

This will tell the manager to stop propagating the notification to other handlers.

Inside Symfony2

Namshi is currently using this library inside their Symfony2 applications.

Add the bundle to your AppKernel.php:

To register a new handler, create a service with the notification.handler tag:

This configuration registers an Emailvision handler.

RabbitMQ

If you use Symfony2 and the RabbitMQBundle you can trigger notifications with this library via RabbitMQ, by using the provided consumer.

Declare the consumer as a service:

Then configure it within the RabbitMQ bundle:

And at that point you can run the consumer with:

To send notifications, the idea is that you serialize them inside the RabbitMQ messages:

That's it!

Built-in handlers

We, at Namshi have developed some very simple, built-in, handlers according to our needs. Keep in mind that the main reason behind building this kind of library is the ability of triggering notification from each component of our SOA, mostly via RabbitMQ.

You can take advantage of the following handlers:

If you have an idea for a new handler, don't hesitate with a pull request: sure, they can be implemented within your own code, but why not sharing them with the OSS ecosystem?

Examples

You can have a look at the few examples provided so far, under the examples directory:

Running specs

In order to run the spec suite after running composer install do the following:


All versions of notificator with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package namshi/notificator contains the following files

Loading the files please wait ....