https://github.com/nimbles-nl/laravel-slack
Laravel Slack package
https://github.com/nimbles-nl/laravel-slack
laravel package php slack
Last synced: 5 months ago
JSON representation
Laravel Slack package
- Host: GitHub
- URL: https://github.com/nimbles-nl/laravel-slack
- Owner: nimbles-nl
- License: mit
- Created: 2018-01-12T12:56:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-01-12T19:36:11.000Z (over 8 years ago)
- Last Synced: 2025-08-04T17:18:05.377Z (11 months ago)
- Topics: laravel, package, php, slack
- Language: PHP
- Homepage: https://www.nimbles.com
- Size: 44.9 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/nimbles-nl/laravel-slack) [](https://packagist.org/packages/nimbles-nl/laravel-slack) [](https://packagist.org/packages/nimbles-nl/laravel-slack) [](https://packagist.org/packages/nimbles-nl/laravel-slack) [](https://codecov.io/gh/nimbles-nl/laravel-slack) [](https://scrutinizer-ci.com/g/nimbles-nl/laravel-slack/?branch=master)
Laravel Slack Package
=====================
A laravel package for sending Slack messages
For more information see [Slack](https://slack.com/)
## Requirements ##
Laravel 5.1 or later
Installation
------------
Installation is a quick 3 step process:
1. Download laravel-slack using composer
2. Configure your HTTP Adapter
3. Enable the package in app.php
4. Configure your Slack credentials
5. (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
``` 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**
``` 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**
``` 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
-----
``` php
$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:
``` php
Slack::sendMessage(new SlackMessage('You are looking great today!'));
````