PHPackages                             jmrashed/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. jmrashed/laravel-slack-notifier

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

jmrashed/laravel-slack-notifier
===============================

A package for sending exceptions and variables to Slack notifications

v1.0.0(1y ago)02MITPHPPHP ^7.1.3 || ^8.0CI passing

Since Feb 14Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

[![Laravel Slack Notifier Package](Notification.png)](Notification.png)

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

[](#laravel-slack-notifier-package)

A simple package to send notifications to Slack using webhooks, with support for customizations such as multiple webhooks, channels, bot name, emojis, and more.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Send Message](#send-message)
    - [Report Exceptions](#report-exceptions)
    - [Dump Variables](#dump-variables)
    - [Multiple Webhooks](#multiple-webhooks)
    - [Send Message to Another Channel](#send-message-to-another-channel)
    - [Customize Slack Bot](#customize-slack-bot)
    - [Message Formatting](#message-formatting)
    - [Additional Context](#additional-context)
    - [Exception Stack Trace Filtering](#exception-stack-trace-filtering)
    - [Cache Same Exceptions](#cache-same-exceptions)
- [Testing](#testing)
- [License](#license)

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

[](#installation)

To install the package, run the following composer command:

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

### Configuration

[](#configuration)

Once the package is installed, you need to set up the environment variables for the Slack webhook and other configuration options.

Add the following entries to your `.env` file:

```
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
```

- `LOG_SLACK_WEBHOOK_URL` is **required** and should be set to your Slack webhook URL. [Learn how to create a webhook](https://api.slack.com/messaging/webhooks).
- The other environment variables are optional. You can set `LOG_SLACK_CHANNEL` to specify a channel or use `LOG_SLACK_EMOJI` to set a custom emoji for the Slack messages.

To temporarily disable notifications, either comment out or set the `LOG_SLACK_WEBHOOK_URL` to an empty string or `null`.

Optionally, you can publish the config file with the following Artisan command:

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

Usage
-----

[](#usage)

### Send Message

[](#send-message)

To send a message to Slack, use the following code:

```
use Jmrashed\SlackNotifier\Facades\SlackNotifier;

SlackNotifier::send('Test message');
```

You can also send exceptions:

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

### Report Exceptions

[](#report-exceptions)

To automatically report exceptions to Slack, configure your Laravel exception handler.

#### Laravel 11.x and later

[](#laravel-11x-and-later)

In `bootstrap/app.php`:

```
return Application::configure(basePath: dirname(__DIR__))
    ->withExceptions(function (Exceptions $exceptions) {
        $exceptions->reportable(function (Throwable $e) {
            \Jmrashed\SlackNotifier\Facades\SlackNotifier::send($e);
        });
    })->create();
```

#### Laravel 8.x, 9.x, and 10.x

[](#laravel-8x-9x-and-10x)

In `app/Exceptions/Handler.php`:

```
public function register(): void
{
    $this->reportable(function (Throwable $e) {
        \Jmrashed\SlackNotifier\Facades\SlackNotifier::send($e);
    });
}
```

#### Laravel 7.x

[](#laravel-7x)

In `app/Exceptions/Handler.php`:

```
public function report(Throwable $exception)
{
    if ($this->shouldReport($exception)) {
        \Jmrashed\SlackNotifier\Facades\SlackNotifier::send($exception);
    }

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

#### Laravel 5.x, 6.x

[](#laravel-5x-6x)

In `app/Exceptions/Handler.php`:

```
public function report(Exception $exception)
{
    if ($this->shouldReport($exception)) {
        \Jmrashed\SlackNotifier\Facades\SlackNotifier::send($exception);
    }

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

### Dump Variables

[](#dump-variables)

You can also send variables (strings, arrays, objects) to Slack:

```
use Jmrashed\SlackNotifier\Facades\SlackNotifier;

$variable = 'message';  // or $variable = ['key' => 'value'];
SlackNotifier::send($variable);
```

### Multiple Webhooks

[](#multiple-webhooks)

You can configure multiple webhook URLs in the `config/slack-notifier.php` file:

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

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

To use a specific webhook, specify the webhook name:

```
use Jmrashed\SlackNotifier\Facades\SlackNotifier;

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

### Send Message to Another Channel

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

To send a message to a different Slack channel, use the `channel` method:

```
use Jmrashed\SlackNotifier\Facades\SlackNotifier;

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

### Customize Slack Bot

[](#customize-slack-bot)

You can customize the bot’s name and emoji:

```
use Jmrashed\SlackNotifier\Facades\SlackNotifier;

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

### Message Formatting

[](#message-formatting)

If you need to format the message before sending, extend the default `SlackNotifierFormatter` class:

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

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

### Additional Context

[](#additional-context)

You can include additional context in the message. Use the `context` method to pass additional information as an attachment in the message.

### Exception Stack Trace Filtering

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

Filter out unnecessary stack trace lines (e.g., from framework files) by configuring the `dont_trace` option in the config.

### Cache Same Exceptions

[](#cache-same-exceptions)

To avoid logging the same exception multiple times, use the `LOG_SLACK_CACHE_SECONDS` configuration. It defines how long exceptions will be cached before being logged again.

Alternatively, you can specify the cache duration programmatically:

```
use Jmrashed\SlackNotifier\Facades\SlackNotifier;

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

Testing
-------

[](#testing)

To run the tests for this package, use the following command:

```
composer test
```

License
-------

[](#license)

This package is licensed under the MIT License. See the [License File](LICENSE.md) for more details.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance43

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

450d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12aeaba318c81d8e123faa3b8961a4e8a1ebf876e2a73b1e1ad08b3e5fc2f901?d=identicon)[jmrashed](/maintainers/jmrashed)

---

Top Contributors

[![jmrashed](https://avatars.githubusercontent.com/u/8583051?v=4)](https://github.com/jmrashed "jmrashed (6 commits)")

---

Tags

laravelloggingnotificationsslackException Reporting

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[saasscaleup/laravel-log-alarm

Laravel log Alarm help you to set up alarm when errors occur in your system and send you a notification via Slack and email

27025.0k](/packages/saasscaleup-laravel-log-alarm)[ytake/laravel-fluent-logger

fluent logger for laravel and lumen

63541.6k1](/packages/ytake-laravel-fluent-logger)[naoray/laravel-github-monolog

Log driver to store logs as github issues

10619.4k](/packages/naoray-laravel-github-monolog)[shaffe/laravel-mail-log-channel

A package to support logging via email in Laravel

1286.2k](/packages/shaffe-laravel-mail-log-channel)

PHPackages © 2026

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