A Stand-Alone Laravel Slack Package

A Stand-Alone Laravel Slack Package

The gpressutto5/laravel-slack composer package is a Slack notification library for Laravel 5.5 by Guilherme Pressutto:

Slack notification for Laravel as it should be. Easy, fast, simple and highly testable. Since it uses On-Demand Notifications, it requires Laravel 5.5 or higher.

You can install this dependency in your Laravel >= 5.5 application with the following:

composer require gpressutto5/laravel-slack

You can publish the configuration file with:

php artisan vendor:publish --provider="Pressutto\LaravelSlack\ServiceProvider"

You will also need to configure an incoming webhook integration for your Slack team.

Basic Usage

Here’s an example of the API interface for the provided Slack service that ships with this package:

// Send a message to a channel
\Slack::to('#finance')->send('Hey, finance channel! A new order was created just now!');

// Send message to users
\Slack::to(['@zoe', '@amy', '@mia'])
    ->send('Here is an example message sent to multiple users');

You can mix it up sending a message to both users and channels at the same time:

\Slack::to('#support', '@bill', '#dev')

You can even send to a user by passing an Eloquent model that has a slack_channel property, or you can provide an accessor method:

class User extends Model
    public function getSlackChannelAttribute(): string
        return $this->attributes['my_custom_slack_channel_column'];
\Slack::to(User::where('verified', true))
    ->send('Sending message to all verified users!');

Here’s a reference to all the configuration values at the time of writing:


return [
    'slack_webhook_url' => env('SLACK_WEBHOOK_URL', ''),
    'default_channel' => '#general',
    'application_name' => env('APP_NAME', null),
    'application_image' => null,


You can easily mock the Slack service by calling Slack::fake() and messages will not be sent to Slack but will be stored in an array. The package ships with some testing helper methods to aid your tests, for example:

Slack::assertSent(function (SlackMessage $message) {
    return $message->content === 'fake';


Learn More

Check out the official GitHub repository and the readme to learn more about this package, including how to write tests for the functionality provided by this package.

Filed in: Laravel Packages / Slack
Laravel News Partners

Laravel Jobs

Senior Full-Time Laravel Developer (REMOTE)
Vue School
Senior Laravel Developer
Remote, USA & Canada Only
Backend Software Engineer
Remote, USA Only
Backend PHP Developer
Senior Developer


Join 31,000+ others and never miss out on new tips, tutorials, and more.