2017 © Pedro Peláez
 

library notify

Framework agnostic and lightweight notification system with several adapters.

image

dstuecken/notify

Framework agnostic and lightweight notification system with several adapters.

  • Wednesday, April 6, 2016
  • by dstuecken
  • Repository
  • 1 Watchers
  • 2 Stars
  • 1,038 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 4 Versions
  • 2 % Grown

The README.md

Notify

Framework agnostic and lightweight notification system implementing the PSR LoggerInterface with several handling adapters., (*1)

Feel free to implement your own handlers!, (*2)

Build Status License Latest Stable Version Latest Unstable Version, (*3)

Requirements

  • PHP 5.4

Installation

Using Composer

To install Notify with Composer, just add the following to your composer.json file:, (*4)

{
    "require": {
        "dstuecken/notify": "dev-master"
    }
}

or by running the following command:, (*5)

composer require dstuecken/notify

Usage

Use the Header Handler

<?php
$notificationCenter = new NotificationCenter();
$notificationCenter->addHandler(
    new HeaderHandler('Notify', NotificationCenter::ERROR)
);

$notificationCenter->error('There was an error.');

The Header handler is used to send an HTTP Header to the Browser in the following (changable) format: X-Notify-Notification. This header can then be grabed by a javascript implementation to display a nice and clean javascript error message while continuing the application with a normal response., (*6)

Use the Logger Handler

You can send your notifications to any LoggerInterface capable logger:, (*7)

<?php
$logger = new Logger('my-logger');

$notificationCenter = new NotificationCenter();
$notificationCenter->addHandler(
    new LoggerHandler($logger, NotificationCenter::ERROR)
);

$notificationCenter->error('There was an error.');

Use the HipChat Handler

You can also send all your CRITICAL notifications to hipchat, for example:, (*8)

<?php
$hipchat = new HipChat\HipChat('apiKey123', );

$notificationCenter = new NotificationCenter();
$notificationCenter->addHandler(
    new HipChatHandler($hipchat, 'hipchat-room-id', NotificationCenter::CRITICAL, 'hipChatBotName')
);

$notificationCenter->error('There was an error.');

Push your notifications to several Handlers

You can send your notifications to different handlers in different levels:, (*9)

<?php
$logger = new Logger('my-logger');

$notificationCenter = new NotificationCenter();
$notificationCenter
    ->addHandler(
        new HeaderHandler(
            'Notify',
            NotificationCenter::INFO
        )
    )
    ->addHandler(
        new LoggerHandler(new Logger(), NotificationCenter::ERROR)
    );

$notificationCenter->error('There was an error.', HeaderHandler::formatAttributes(null, null, true));

Currently implemented Handlers

Sends an HTTP Header, which can be observed by Javascript to represent errors as growl-like notification messages., (*10)

Logger

Forwards your notifications to a Logger, which implements the LoggerInterface., (*11)

MacOS

Displays a Mac OS X Notification Center Message., (*12)

HipChat

Drops notifications on your hipchat rooms., (*13)

NotifySend

Notify via Ubuntu's notification service., (*14)

Syslog

Send your notifications to a syslog (using the PHP syslog() function)., (*15)

Smarty

Attach your notifications to a smarty template variable, (*16)

Memory

Forward notifications to an array, (*17)

Tests

Run phpunit tests with, (*18)

phpunit --bootstrap tests/bootstrap.php tests

The Versions

06/04 2016

dev-master

9999999-dev

Framework agnostic and lightweight notification system with several adapters.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dstuecken

logger abstraction notification flash notify

06/04 2016

1.0.3

1.0.3.0

Framework agnostic and lightweight notification system with several adapters.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dstuecken

logger abstraction notification flash notify

22/12 2015

1.0.1

1.0.1.0

Framework agnostic and lightweight notification system with several adapters.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dstuecken

logger abstraction notification flash notify

27/10 2015

1.0

1.0.0.0

Framework agnostic and lightweight notification system with several adapters.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar dstuecken

logger abstraction notification flash notify