PHPackages                             joelhinz/laravel-quick-slack - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Mail &amp; Notifications](/categories/mail)
4. /
5. joelhinz/laravel-quick-slack

ActiveLibrary[Mail &amp; Notifications](/categories/mail)

joelhinz/laravel-quick-slack
============================

An easy way of quickly sending messages to predefined Slack endpoints within a Laravel project.

0.5.0(4y ago)0210MITPHPCI failing

Since Nov 3Pushed 4y ago1 watchersCompare

[ Source](https://github.com/joelhinz/laravel-quick-slack)[ Packagist](https://packagist.org/packages/joelhinz/laravel-quick-slack)[ RSS](/packages/joelhinz-laravel-quick-slack/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (2)Versions (8)Used By (0)

Laravel QuickSlack
==================

[](#laravel-quickslack)

A simple package to quickly send messages to Slack channels through Laravel. Tested with Laravel 5.4 through 8.

Installation
------------

[](#installation)

Use Composer to install the package:

```
composer require "joelhinz/laravel-quick-slack=0.*"
```

This package supports auto-discovery, so if you're using Laravel 5.5, you're all set.

For Laravel 5.4, or if you don't want to use auto-discovery, add the provider and optionally the facade alias to your `config/app.php` file:

```
'providers' => [
    // ...
    JoelHinz\LaravelQuickSlack\ServiceProvider::class,
],

'aliases' => [
    // ...
    'QuickSlack' => JoelHinz\LaravelQuickSlack\Facade::class,
],
```

Basic usage
-----------

[](#basic-usage)

Before sending messages, all you need to do is go to Slack and [create an incoming webhook](https://www.slack.com/services/new/incoming-webhook), then copy the webhook url.

```
use QuickSlack;

QuickSlack::to($webhook)->send('My hovercraft is full of eels.');
```

The webhook url can be remembered for subsequent calls during the same script execution by passing a boolean as the second argument to the `to()` method:

```
# Remember webhook for next call
QuickSlack::to($webhook, true)->send('My nipples explode with delight!');

# No need for the to() method this time
QuickSlack::send('I cannot wait till lunchtime.');

# Set a new webhook - the new webhook will now be remembered instead
QuickSlack::to($webhook)->send('Drop your panties, Sir William!');

# Set a new webhook but stop remembering
QuickSlack::to($webhook, false)->send('Bouncy-bouncy');

# Stop remembering without sending a message
QuickSlack::forgetRecipient();
```

Since QuickSlack is fluent, you can just keep chaining more messages if you want to. Please note that this requires a remembered webhook url, or a default webhook (see configuration options below).

```
QuickSlack::send('first message')->send('second message')->send('third message');
```

Don't like how long the webhook urls get? No worries, you can just skip the first part of them. Instead of `https://hooks.slack.com/services/[rest of url]`, just enter everything after `services/` instead. QuickSlack will handle the rest automatically.

Configuration
-------------

[](#configuration)

QuickSlack can be used without any configuration, but you can export the configuration to get features such as a default webhook and named webhooks.

```
php artisan vendor:publish --provider="JoelHinz\LaravelQuickSlack\ServiceProvider"
```

This will create a file `config/quick-slack.php` where you can set your configuration options as follows:

```
