t1l3/slack-notifier-bundle
Composer 安装命令:
composer require t1l3/slack-notifier-bundle
包简介
A simple wrapper for Slack notifications
关键字:
README 文档
README
A simple wrapper for polem/slack-notifier to send Slack notifications.
Installation
Download T1l3SlackNotifier using composer
Add T1l3SlackNotifier in your composer.json:
{
"require": {
"t1l3/slack-notifier-bundle": "0.1"
}
}
Now tell composer to download the bundle by running the command:
$ php composer.phar update t1l3/slack-notifier-bundle
Enable the bundle
Enable the bundle in the kernel:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new T1l3\SlackNotifierBundle\T1l3SlackNotifierBundle(), ); }
Configure T1l3SlackNotifier
First you need to create an incoming-webhook in Slack to get your token. You can also set default Bot name and icon in the Integration Settings part.
Then add it to your config.yml
# app/config/config.yml t1l3_slack_notifier: team: yourteam token: yOurT0ken
Usage
You just have to call t1l3_slack_notifier service and add a Slack\Message\Message to the notify method.
Here is a simple exemple of using it in a controller.
<?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); // ... } }
统计信息
- 总下载量: 395
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-05-22