2017 © Pedro Peláez
 

library notify

A PHP notification library for sending messages to various platforms

image

noveth/notify

A PHP notification library for sending messages to various platforms

  • Wednesday, September 23, 2015
  • by noveth2012
  • Repository
  • 1 Watchers
  • 0 Stars
  • 24 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 9 Versions
  • 0 % Grown

The README.md

Notify Build Status

Notification library, (*1)

Description

A PHP Library that will be used for sending notifications to multiple providers., (*2)

Implementations

Current

  • Email
  • Slack

Planned

  • HipChat

Requirements

  • PHP 5.4+
  • CURL

Installation

Using Composer

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

{
    "require": {
        "noveth/notify": "0.*"
    }
}

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

composer require noveth/notify

Usage

Configuration

There is a default configuration included and falls back to if no user configuration is found. To start using a custom configuration rename Config.php.example to Config.php., (*5)

Email

Sending an email with Notify is incredibly simple, you pass 3 parameters and it will return true or false., (*6)

bool Notify\Email::send(string $to, string $subject, string $template [, array $replace ] );

There are 3 required parameters used in the send method with an optional 4th parameter if you use string replacement in your templates., (*7)

Here is an example of the parameters:, (*8)

// Target email address
$to = 'example@example.com';

// Subject line
$subject = 'An example email';

// Template file name
// You can tell Notify if its a html email or not depending on the file extension
// .html files will automatically be sent as a html email
$template = 'user/registration.html';

// If you use tags in your template this is where you pass what to replace them with
$replace = [
  'test tag' => 'test content'
];

Slack

Notifications can also be sent to slack but requires a bit more setup than using email (dont worry its not too difficult). To use Slack notifications you need to setup a webhook on your slack team settings first., (*9)

Follow the Configuration step above to start using a custom configuration and then add the following lines to your Config.php file., (*10)

// Replace {YOUR_ENDPOINT} with the webhook URL provided by slack.
Config::$SLACKWEBHOOK = '{YOUR_ENDPOINT}';
// Replace {NAME_OF_USER} with the user you want the message to be sent as (this can be anything).
Config::$SLACKUSERNAME = '{NAME_OF_USER}';

Slack notifications are sent in a similar fashion to Emails but only has 1 required parameter and 1 optional., (*11)

bool Notify\Slack::send(string $message [, string $target]);

The second parameter can either be a room or a user, this is done by following the syntax below. If its not sent it will use the default room set in your webhook settings on slack., (*12)

$target = '#channel';
$target = '@user';

The Versions

23/09 2015

dev-development

dev-development https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify

23/09 2015

dev-master

9999999-dev https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify

23/09 2015

0.2.5

0.2.5.0 https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify

23/09 2015

0.2.4

0.2.4.0 https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify

08/09 2015

0.2.3

0.2.3.0 https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify

07/09 2015

0.2.2

0.2.2.0 https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify

07/09 2015

0.2.1

0.2.1.0 https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify

07/09 2015

0.2.0

0.2.0.0 https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify

07/09 2015

0.1.0

0.1.0.0 https://github.com/noveth/Notify

A PHP notification library for sending messages to various platforms

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

notification notify