dev-master
9999999-devA simple wrapper for Slack notifications
MIT
The Requires
by Thibault PIERRE
slack
0.1
0.1.0.0A simple wrapper for Slack notifications
MIT
The Requires
by Thibault PIERRE
slack
Wallogit.com
2017 © Pedro Peláez
A simple wrapper for Slack notifications
A simple wrapper for polem/slack-notifier to send Slack notifications., (*1)
Add T1l3SlackNotifier in your composer.json:, (*2)
{
"require": {
"t1l3/slack-notifier-bundle": "0.1"
}
}
Now tell composer to download the bundle by running the command:, (*3)
$ php composer.phar update t1l3/slack-notifier-bundle
Enable the bundle in the kernel:, (*4)
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new T1l3\SlackNotifierBundle\T1l3SlackNotifierBundle(),
);
}
First you need to create an [incoming-webhook][3] in Slack to get your token. You can also set default Bot name and icon in the Integration Settings part., (*5)
Then add it to your config.yml, (*6)
# app/config/config.yml
t1l3_slack_notifier:
team: yourteam
token: yOurT0ken
You just have to call t1l3_slack_notifier service and add a Slack\Message\Message to the notify method., (*7)
Here is a simple exemple of using it in a controller., (*8)
<?php
namespace Acme\DemoBundle\Controller;
// ...
use Slack\Message\Message;
class DefaultController extends Controller
{
public function indexAction()
{
$message = new Message('Hello World!');
$message->setChannel('#your-chanel')
->setIconEmoji(':princess:')
->setUsername('Bot')
;
$slackNotifier = $this->get('t1l3_slack_notifier');
$slackNotifier->notify($message);
// ...
}
}
A simple wrapper for Slack notifications
MIT
slack
A simple wrapper for Slack notifications
MIT
slack