mvaliolahi/notify

Framework agnostic PHP library to simplify interact with common messaging platforms.

v0.0.1 2018-03-04 17:33 UTC

This package is auto-updated.

Last update: 2024-05-09 23:05:29 UTC


README

Framework agnostic PHP library to simplify interact with common messaging platforms, but Slack for now!

Install

composer require mvaliolahi/notify

Getting start

$notify = new Notify(new SlackDriver([
    'web_hook' => 'your slack web-hook'
]));

$notify->send((new Slack)->text('Hello World!'));

Develop Guide

What is a bot? / How can i create a new one?

Bot is a definition for any class that implements Mvaliolahi\Notify\Contracts\Bot, bot can interact with user to collect all necessary information to pass into $notify->send() method.

when bots passed to $notify->send(), the notify object is able to send this information to any messaging platform, obviously using specified Driver.

What is driver? / How can i implement it for other platforms?

Driver is a class that implements Mvaliolahi\Notify\Contracts\Driver, the only responsibility of driver is fetching essential data from $bot object, and implement related logic to send through messaging-platform.

it is clear enough that$notify->send() is just a wrapper around driver execute() method.

Slack Bot

The code shows you everything :)

(new Slack)
->text('Normal text')
->format()->pre('text') // like <pre> tag in html
->format()->bold('Bold text.')
->format()->italic('Italic text.')
->format()->blockQuotes('Italic text.')
->format()->strikeThrough('Italic text.')
->format()->code('<p> The only thing we need is just words.</p>')