jivesh/laravel-slack

A minimalist laravel integration for Slack
36,737 25
Install
composer require jivesh/laravel-slack
Latest Version:2.1.2
License:MIT
Last Updated:Jun 30, 2018
Links: GitHub  ·  Packagist
Maintainer: gahlawat

laravel-slack

Author Travis Quality Score Code Climate Total Downloads Packagist Version Software License SensioLabsInsight

A very tiny and lightweight integration with the Slack API for posting notifications or any kind of messages to your team's Slack account.


Requirements

  • Laravel Framework 5+

Installation

Using Composer package manager, install this package by running following command in your project root:

$ composer require jivesh/laravel-slack

Registering the Package

  • This package supports auto discovery feature introduced in Laravel v5.5, hence it is auto registered. You may skip to 'Configuration' section below.

  • If your app is on Laravel v5.4 or below, follow below steps to register:

  • In your config/app.php file, append the following code into your providers array for integrating the Service Provider for package.

/**
 * Package Service Provider
 */

'providers' => [
    // ...

    Gahlawat\Slack\SlackServiceProvider::class,
],
  • Again in your config/app.php file, copy the following code into your aliases array for a nice Laravel syntax using Facades.
/**
 * Package Alias
 */

'aliases' => [
    // ...

    'Slack' => Gahlawat\Slack\Facade\Slack::class,
],

Configuration

  • Create an incoming webhook on your Slack account for the package to use and copy the generated Webhook URL.

  • Run the following command in project root directory to generate config file for package.

$ php artisan vendor:publish
  • Now edit config/slack.php and paste value for incoming-webhook generated in the first step above.
  • You may optionally set a default username and emoji icon displayed in your Slack app from here.

Usage

  • Send any message in real time to your Slack account using this anywhere in your php code:
\Slack::send("your-message");
  • The backslash indicates global namespace scope for this function, you may import Slack namespace on top of your file by using it:
use Slack;
  • Then, you can call this Facade without a \ as:
Slack::send("your-message");
  • You can change the default name and/or display icon in your Slack app for any message by using optional second and third parameter.
  • To send this message privately to any user, use the fourth parameter as @username
  • To send this message publicly to any channel, use the fourth parameter as #channel
Slack::send("your-message" [,"display-name" [,"display-emoji"] [,"#channel" or "@username"]]);

// here [] indicates optional parameters

See this cheat sheet of available emoji icons.

Related Packages

jakebathman/laravel-slack-api

Wrapper for Slack.com WEB API. Based on code from Vagner do Carmo.

58 0
razorpay/slack-laravel

Laravel 4 and 5 integration for the razorpay/slack package, including facades an...

376,804 18
cadicvnn/slack-laravel

Laravel 4 and 5 integration for the maknz/slack package, including facades and s...

40 0
bluora/php-slack

A simple PHP package for sending messages to Slack, with a focus on ease of use...

32 0
hnhdigital-os/laravel-slack

Laravel integration for the hnhdigital-os/php-slack package.

12 0