Download the PHP package emmanix2002/notifier without Composer

On this page you can find all versions of the php package emmanix2002/notifier. 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 notifier

Notifier

Latest Version on Packagist Build Status Total Downloads

A library for handling and processing notifications.

Installation

To install the package, you simply run:

composer require emmanix2002/notifier

Introduction

The notifier works using the the following concepts:

By default, 2 handlers are provided to get you started:

Process Flow

This is the expected flow for using the notifier:

  1. Create an instance of Notifier (you can use the Notifier::instance() to have a shared instance through the application)
  2. (optional) Add one or more Processors to the Notifier
  3. Create your Message (for instance, you could create an SmsMessage)
  4. Create your Recipient (e.g. for SMS, we need a phone number, we could say $recipients = new RecipientCollection(['2348123456789'], PhoneRecipient::class);)
  5. Call your Notifier::notify($message, $recipients)

So it flows like:

Notifier -> (Processors) -> Channels -> (Processors) -> Handlers

You see (Processors) appear twice, here's why:

Message

A message is an instance of Emmanix2002\Notifier\Message\MessageInterface. A MessageInterface implementation encapsulates the data that is to be sent out to the recipients.

A few message types are provided by default:

Recipient Collection

The RecipientCollection represents a list/collection of destinations that the notification should be sent to; it also tries to understand how to interpret each of these addresses (it does so from the second __construct() parameter).

A recipient is an instance of Emmanix2002\Notifier\Recipient\RecipientInterface; all recipients are expected to implement this interface.

Some default recipient classes are provided with the package:

The first parameter of the RecipientCollection constructor supports 3 forms:

  1. An array of strings e.g. $collection = new RecipientCollection(['[email protected]', ...], EmailRecipient::class);
    when looping through (or when accessing an index - $collection[0] - it returns an instance of the second argument which is a class that implements RecipientInterface).
    It does so by passing each string element of the array as the first argument of the class recipient constructor.

  2. An array of RecipientInterface instances. You can see this from the examples/email-notify.php example file.
    Even though it's an array of RecipientInterface instances, you still need to pass the second parameter.
    Like before, when looping or accessing an offset of the collection, you'll get a RecipientInterface instance.

  3. An array with a form representing the constructor form of the desired RecipientInterface implementation. Take a look at the examples/email-notify-using-address-array.php example.
    This form is the most flexible because it allows you to keep your code simple and clean, without having to create too many objects until you really need to.
    It splits the array and passes the indexes as the arguments to the __construct() method of the instance. For instance, it passes index 0 as the first parameter, index 1 as the second parameter, and so forth.

Each of the files inside the examples directory highlight these 2 forms. So, feel free to create your own RecipientInterface implementations.

Handlers

Handlers are instances of HandlerInterface (see Introduction). When you create a channel, you either pass the handlers in the constructor, or you add them one at a time on the created Channel.

Handlers are the actual mechanism that send out the notifications; without handlers, a channel basically does nothing.
Handlers added to a channel are stored in a stack (i.e. Last-In, First-Out - LIFO); meaning, the last handler added to a channel gets executed first.

After a handler is called, and it completes execution, it returns either a boolean value or any other value as required, that informs the notifier whether or not the request (i.e. Message and RecipientCollection) should be passed to the next handler for processing:

Handlers must define a propagate(): bool method on themselves to describe the propagate preference for the handler.
By default, all handlers that extend the AbstractHandler class return false - meaning they don't propagate.

Usage

See the examples directory for more.


All versions of notifier with dependencies

PHP Build Version
Package Version
Requires php Version ~7.0
guzzlehttp/guzzle Version ~6.2
monolog/monolog Version ^1.22
symfony/var-dumper Version ^3.2
vlucas/phpdotenv Version ^2.4
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 emmanix2002/notifier contains the following files

Loading the files please wait ....