PHPackages                             stasadev/laravel-slack-notifier - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. stasadev/laravel-slack-notifier

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

stasadev/laravel-slack-notifier
===============================

Send exceptions and dump variables to Slack

1.1.1(1y ago)0941MITPHPPHP ^7.1.3 || ^8.0CI passing

Since Jul 2Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/stasadev/laravel-slack-notifier)[ Packagist](https://packagist.org/packages/stasadev/laravel-slack-notifier)[ Docs](https://github.com/stasadev/laravel-slack-notifier)[ RSS](/packages/stasadev-laravel-slack-notifier/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (6)Versions (4)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4be9e1a44270978f9f0e535dfcefe7a40bb73c24438cd3d11ea02b623293e070/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73746173616465762f6c61726176656c2d736c61636b2d6e6f7469666965722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stasadev/laravel-slack-notifier)[![GitHub Tests Action Status](https://camo.githubusercontent.com/abcdf1298ddc94f8f4922917bc7be280c9ee6f252ddff31680ab3b3dfc01f994/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73746173616465762f6c61726176656c2d736c61636b2d6e6f7469666965722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/stasadev/laravel-slack-notifier/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/7cf6b0615d24f37846cb53082feb5a67bd2f81a0e156c3d49674aaba969aa914/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73746173616465762f6c61726176656c2d736c61636b2d6e6f7469666965722f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/stasadev/laravel-slack-notifier/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/4216dd0a5e9dec84d4bc4fc6e21c1743d96d8a45efd5201f32757a2baa570875/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73746173616465762f6c61726176656c2d736c61636b2d6e6f7469666965722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/stasadev/laravel-slack-notifier)

Laravel Slack Notifier
======================

[](#laravel-slack-notifier)

Send exceptions and dump variables to Slack.

```
use Stasadev\SlackNotifier\Facades\SlackNotifier;

SlackNotifier::send(new \RuntimeException('Test exception'));
SlackNotifier::send('Test message');
```

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

[](#installation)

Install the package via composer:

```
composer require stasadev/laravel-slack-notifier
```

All env variables used by this package (only `LOG_SLACK_WEBHOOK_URL` is required):

```
APP_NAME=Laravel
LOG_SLACK_WEBHOOK_URL=https://hooks.slack.com/services/ABC
LOG_SLACK_CHANNEL=
LOG_SLACK_EMOJI=:boom:
LOG_SLACK_CACHE_SECONDS=0
```

How to get a webhook URL [in the Slack API docs](https://api.slack.com/messaging/webhooks).

To temporarily disable all logging, simply comment out `LOG_SLACK_WEBHOOK_URL` or set it to an empty string or `null`.

Optionally publish the [config](./config/slack-notifier.php) file with:

```
php artisan vendor:publish --tag="slack-notifier"
```

Usage
-----

[](#usage)

To send a message to Slack, simply call `SlackNotifier::send()`.

Report Exception
----------------

[](#report-exception)

```
// In Laravel 11.x and later
// bootstrap/app.php
return Application::configure(basePath: dirname(__DIR__))
    ->withExceptions(function (Exceptions $exceptions) {
        $exceptions->reportable(function (Throwable $e) {
            \Stasadev\SlackNotifier\Facades\SlackNotifier::send($e);
        });
    })->create();

// In Laravel 8.x, 9.x, 10.x
// app/Exceptions/Handler.php
public function register(): void
{
    $this->reportable(function (Throwable $e) {
        \Stasadev\SlackNotifier\Facades\SlackNotifier::send($e);
    });
}

// In Laravel 7.x
// app/Exceptions/Handler.php
public function report(Throwable $exception)
{
    if ($this->shouldReport($exception)) {
        \Stasadev\SlackNotifier\Facades\SlackNotifier::send($exception);
    }

    parent::report($exception);
}

// In Laravel 5.7.x, 5.8.x, 6.x
// app/Exceptions/Handler.php
public function report(Exception $exception)
{
    if ($this->shouldReport($exception)) {
        \Stasadev\SlackNotifier\Facades\SlackNotifier::send($exception);
    }

    parent::report($exception);
}
```

Dump Variable
-------------

[](#dump-variable)

```
use Stasadev\SlackNotifier\Facades\SlackNotifier;

$variable = 'message';
// $variable = ['test' => 'array'];
// $variable = new stdClass();

SlackNotifier::send($variable);
```

Using multiple webhooks
-----------------------

[](#using-multiple-webhooks)

Use an alternative webhook, by specify extra ones in the config file.

```
// config/slack-notifier.php

'webhook_urls' => [
    'default' => 'https://hooks.slack.com/services/ABC',
    'testing' => 'https://hooks.slack.com/services/DEF',
],
```

The webhook to be used can be chosen using the `to` function.

```
use Stasadev\SlackNotifier\Facades\SlackNotifier;

SlackNotifier::to('testing')->send('Test message');
```

### Using a custom webhooks

[](#using-a-custom-webhooks)

The `to` function also supports custom webhook URLs.

```
use Stasadev\SlackNotifier\Facades\SlackNotifier;

SlackNotifier::to('https://custom-url.com')->send('Test message');
```

Sending message to another channel
----------------------------------

[](#sending-message-to-another-channel)

You can send a message to a channel (use `LOG_SLACK_CHANNEL`) other than the default one for the webhook, by passing it to the `channel` function.

```
use Stasadev\SlackNotifier\Facades\SlackNotifier;

SlackNotifier::channel('reminders')->send('Test message');
```

Slack bot customizing
---------------------

[](#slack-bot-customizing)

Use `username` (use `APP_NAME`) and `emoji` (use `LOG_SLACK_EMOJI`) to make your messages unique, or override them right before sending.

```
use Stasadev\SlackNotifier\Facades\SlackNotifier;

SlackNotifier::username('My Laravel Bot')->emoji(':tada:')->send('Test message');
```

### Formatting

[](#formatting)

Extend the default `Stasadev\SlackNotifier\SlackNotifierFormatter::class` to format the messages however you like. Then simply replace the `formatter` key in the configuration file.

```
// config/slack-notifier.php

'formatter' => App\Formatters\CustomSlackNotifierFormatter::class,
```

### Additional context in the message

[](#additional-context-in-the-message)

Include additional `context` in a Slack message (use `dont_flash` to exclude sensitive info from `context`). It will be added as an attachment.

### Exception stack trace filtering

[](#exception-stack-trace-filtering)

Stack traces for exceptions in Laravel usually contain many lines, including framework files. Usually, you are only interested in tracking exception details in the application files. You can filter it out with the `dont_trace` config option.

### Caching the same exceptions

[](#caching-the-same-exceptions)

Sometimes a large group of exceptions is thrown, and you don't want to log each of them because they are the same.

Use `LOG_SLACK_CACHE_SECONDS` (uses Laravel cache under the hood) to suppress output for X seconds, or pass it to the `cacheSeconds` function.

```
use Stasadev\SlackNotifier\Facades\SlackNotifier;

SlackNotifier::cacheSeconds(60)->send(new \RuntimeException('Test exception'));
```

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

Inspired by [spatie/laravel-slack-alerts](https://github.com/spatie/laravel-slack-alerts).

- [Stanislav Zhuk](https://github.com/stasadev)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance60

Regular maintenance activity

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 60% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~305 days

Total

3

Last Release

435d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/19ac0e08a347776245ddd7a701c8f66f6bd0b48cd2c8f9d029340f4ec24fb55d?d=identicon)[stasadev](/maintainers/stasadev)

---

Top Contributors

[![stasadev](https://avatars.githubusercontent.com/u/24270994?v=4)](https://github.com/stasadev "stasadev (12 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (8 commits)")

---

Tags

laravelloggingphpslacklaravelnotificationsslack

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/stasadev-laravel-slack-notifier/health.svg)

```
[![Health](https://phpackages.com/badges/stasadev-laravel-slack-notifier/health.svg)](https://phpackages.com/packages/stasadev-laravel-slack-notifier)
```

###  Alternatives

[tylercd100/lern

LERN (Laravel Exception Recorder and Notifier) is a Laravel 5 package that will record exceptions into a database and will notify you via Email, Pushover or Slack.

438153.4k3](/packages/tylercd100-lern)[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8674.9k](/packages/illuminated-console-logger)[guanguans/laravel-exception-notify

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

14642.7k1](/packages/guanguans-laravel-exception-notify)[tylercd100/laravel-notify

12152.1k1](/packages/tylercd100-laravel-notify)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
