nimbles-nl / laravel-slack
Laravel package for sending slack messages
v1.0.0
2018-01-12 13:40 UTC
Requires
- php: >=5.5.9
- guzzlehttp/psr7: 1.4.*
- illuminate/support: ^5.1
- php-http/httplug: 1.1.*
Requires (Dev)
- php-http/mock-client: ^1.0
- phpunit/phpunit: ^6.1
This package is not auto-updated.
Last update: 2024-11-10 05:30:00 UTC
README
Laravel Slack Package
A laravel package for sending Slack messages
For more information see Slack
Requirements
Laravel 5.1 or later
Installation
Installation is a quick 3 step process:
- Download laravel-slack using composer
- Configure your HTTP Adapter
- Enable the package in app.php
- Configure your Slack credentials
- (Optional) Configure the package facade
Step 1: Download laravel-slack using composer
Add nimbles-nl/laravel-slack by running the command:
composer require nimbles-nl/laravel-slack
Step 2: Configure you HTTP Adapter in your service container
Configure the http adapter in your AppServiceProvider.php
use GuzzleHttp\Client as GuzzleClient; use Http\Adapter\Guzzle6\Client as GuzzleAdapter; $this->app->singleton('http.client', function() { return new GuzzleAdapter(new GuzzleClient()); });
Step 3: Enable the package in app.php
Register the Service in: config/app.php
Nimbles\Slack\SlackServiceProvider::class,
Step 4: Configure Slack credentials
php artisan vendor:publish
Add this in you .env file
SLACK_ACCESS_TOKEN=your_secret_slack_access_token
Step 5 (Optional): Configure the package facade
Register the Slack Facade in: config/app.php
'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, ... 'Slack' => Nimbles\Slack\Facade\Slack::class,
Usage
$slackMessage = new SlackMessage('You re looking great today!', '#general', 'AwesomeBot', 'https://www.link-to-avatar.com/image.png'); app('slack')->sendMessage($slackMessage);
Or if you want to use facade, add this in your class after namespace declaration:
Slack::sendMessage(new SlackMessage('You are looking great today!'));