Beep :mega:
Beep is a lightweight Laravel package for sending notifications to your team via Slack and HipChat. Inspiration and the initial code was taken from Laravel Envoy., (*1)
Installation
Require the seleznev/beep
package using Composer:, (*2)
composer require seleznev/beep
Add the service provider in config/app.php
to providers
array:, (*3)
Seleznev\Beep\ServiceProvider::class,
Add the alias in config/app.php
to aliases
array:, (*4)
'Beep' => Seleznev\Beep\Facade::class,
For the Laravel 5.0.* you should add 'Seleznev\Beep\ServiceProvider',
and 'Beep' => 'Seleznev\Beep\Facade',
respectively., (*5)
Configuration
To get started, you'll need to create a Slack token or a HipChat token., (*6)
Add your SLACK_TOKEN
and HIPCHAT_TOKEN
to the .env
file., (*7)
Usage
Send a message to a Slack channel:, (*8)
Beep::slack('#channel')->say('Hi');
Send a message to a HipChat room:, (*9)
Beep::hipchat('room')->say('Hi');
Send a message from a chosen name:, (*10)
Beep::slack('#channel')->from('My application')->say('Hi');
A few attractive examples:, (*11)
public function report(Exception $e)
{
parent::report($e);
$message = App::environment().': '.$e->getMessage();
Beep::slack('#logs')->say($message);
}
Post::created(function ($post) {
$message = "*{$post->user->name}* has created _{$post->title}_ post!";
Beep::slack('#activity')->say($message);
});
Post::created(function ($post) {
$message = "<b>{$post->user->name}</b> has created <i>{$post->title}</i> post!";
Beep::hipchat('activity')->say($message);
});
Lumen
Add the service provider in bootstrap/app.php
to Register Service Providers
block:, (*12)
$app->register(Seleznev\Beep\ServiceProvider::class);
app('beep')->slack('#channel')->say('Lumen');
License
Beep is licensed under The MIT License (MIT)., (*13)