Skip to content

Instantly share code, notes, and snippets.

@rmarganti
Created March 29, 2017 16:49
Show Gist options
  • Select an option

  • Save rmarganti/05ba8144ec2adac1b2a3be1aba26b1f9 to your computer and use it in GitHub Desktop.

Select an option

Save rmarganti/05ba8144ec2adac1b2a3be1aba26b1f9 to your computer and use it in GitHub Desktop.
Lumen App Service Provider for `maknz/slack-laravel`
<?php
namespace App\Providers;
use Maknz\Slack\Client as Client;
use GuzzleHttp\Client as Guzzle;
class SlackServiceProvider extends \Illuminate\Support\ServiceProvider
{
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->configure('slack');
$this->mergeConfigFrom(
base_path('vendor/maknz/slack/src/config/config.php'),
'slack'
);
$this->app['maknz.slack'] = $this->app->share(function ($app) {
return new Client(
$app['config']->get('slack.endpoint'),
[
'channel' => $app['config']->get('slack.channel'),
'username' => $app['config']->get('slack.username'),
'icon' => $app['config']->get('slack.icon'),
'link_names' => $app['config']->get('slack.link_names'),
'unfurl_links' => $app['config']->get('slack.unfurl_links'),
'unfurl_media' => $app['config']->get('slack.unfurl_media'),
'allow_markdown' => $app['config']->get('slack.allow_markdown'),
'markdown_in_attachments' => $app['config']->get('slack.markdown_in_attachments'),
],
new Guzzle
);
});
$this->app->bind('Maknz\Slack\Client', 'maknz.slack');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment