PHPackages                             mwakaambrose/laravel-slack-alert - 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. mwakaambrose/laravel-slack-alert

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

mwakaambrose/laravel-slack-alert
================================

Send a message to Slack

1.5(3y ago)0755MITPHPPHP ^8.0

Since Aug 25Pushed 3y agoCompare

[ Source](https://github.com/mwakaambrose/laravel-slack-alerts)[ Packagist](https://packagist.org/packages/mwakaambrose/laravel-slack-alert)[ Docs](https://github.com/mwakaambrose/laravel-slack-alert)[ RSS](/packages/mwakaambrose-laravel-slack-alert/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (6)Dependencies (13)Versions (7)Used By (0)

Quickly send a message to Slack | Extendable for building slack bots/apps
=========================================================================

[](#quickly-send-a-message-to-slack--extendable-for-building-slack-botsapps)

This package can quickly send alerts to Slack. You can use this to notify yourself of any noteworthy events happening in your app.

```
use MwakaAmbrose\SlackAlert\Facades\SlackAlert;

SlackAlert::string("You have a new subscriber to the {$newsletter->name} newsletter!");
```

Under the hood, a job is used to communicate with Slack. This prevents your app from failing in case Slack is down.

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

[](#installation)

You can install the package via composer:

```
composer require mwakaambrose/laravel-slack-alert
```

You can set a `SLACK_ALERT_WEBHOOK` env variable containing a valid Slack webhook URL. You can learn how to get a webhook URL [in the Slack API docs](https://api.slack.com/messaging/webhooks).

Alternatively, you can publish the config file with:

```
php artisan vendor:publish --tag="slack-alert-config"
```

This is the contents of the published config file:

```
return [
    /*
     * The webhook URLs that we'll use to send a message to Slack.
     */
    'webhook_urls' => [
        'default' => env('SLACK_ALERT_WEBHOOK'),
    ],
];
```

Usage
-----

[](#usage)

To send a message to Slack, simply call `SlackAlert::string()` and pass it any message you want.

```
SlackAlert::string("You have a new subscriber to the {$newsletter->name} newsletter!");
```

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

[](#using-multiple-webhooks)

You can also use an alternative webhook, by specify extra ones in the config file.

```
// in config/slack-alert.php

'webhook_urls' => [
    'default' => 'https://hooks.slack.com/services/XXXXXX',
    'marketing' => 'https://hooks.slack.com/services/YYYYYY',
],
```

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

```
use MwakaAmbrose\SlackAlert\Facades\SlackAlert;

SlackAlert::to('marketing')->string("You have a new subscriber to the {$newsletter->name} newsletter!");
```

### Using a custom webhooks

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

The `to` function also supports custom webhook urls.

```
use MwakaAmbrose\SlackAlert\Facades\SlackAlert;

SlackAlert::to('https://custom-url.com')->message("You have a new subscriber to the {$newsletter->name} newsletter!");
```

Formatting
----------

[](#formatting)

### Markdown

[](#markdown)

You can format your messages with Slack's markup. Learn how [in the Slack API docs](https://slack.com/help/articles/202288908-Format-your-messages).

```
use MwakaAmbrose\SlackAlert\Facades\SlackAlert;

SlackAlert::string("A message *with some bold statements* and _some italicized text_.");
```

Links are formatted differently in Slack than the classic markdown structure.

```
SlackAlert::string("");
```

### Emoji's

[](#emojis)

You can use the same emoji codes as in Slack. This means custom emoji's are also supported.

```
use MwakaAmbrose\SlackAlert\Facades\SlackAlert;

SlackAlert::string(":smile: :custom-code:");
```

### Mentioning

[](#mentioning)

You can use mentions to notify users and groups. Learn how [in the Slack API docs](https://api.slack.com/reference/surfaces/formatting#mentioning-users).

```
use MwakaAmbrose\SlackAlert\Facades\SlackAlert;

SlackAlert::string("A message that notifies  and everyone else who is ")
```

### Sending an exception

[](#sending-an-exception)

Yo can send an exception to slack by calling the exception function and passing in any instance of throwable. You will receive the message, file, line number and apps environment on slack.

```
SlackAlert::to("failed_vsla_wallet")->exception(new \Exception("This is a test exception"));
```

### More advanced

[](#more-advanced)

You can pass a callback function the returns an instance of `SlackPhp\Blockkit\Surfaces\Message` to construct your own robust message blocks in slack. See [the packaages home](https://github.com/slack-php/slack-php-block-kit/tree/1.0.0) for more information.

```
SlackAlert::to('failed_vsla_wallet')->send(function(){
    $msg = Message::new();
    // Then you can add blocks using the surface's available methods.
    $msg->text('Don\'t you just love Slack?');
    $msg->divider();
    $msg->newImage()
        ->title('Team Chat')
        ->url('https://imgs.xkcd.com/comics/team_chat.png')
        ->altText('Comic about the stubbornness of some people switching chat clients');

    return $msg;
});
```

Testing
-------

[](#testing)

```
composer test
```

Credits
-------

[](#credits)

- [slack-php/slack-php-block-kit](https://github.com/slack-php/slack-php-block-kit/tree/1.0.0)
- [spatie/laravel-slack-alert](https://github.com/spatie/laravel-slack-alert)
- [Niels Vanpachtenbeke](https://github.com/Nielsvanpach)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~14 days

Total

6

Last Release

1282d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/db5111c1c45c26d510cca26fc1db9f7655b59898ac2e53f90e8d4c66fe37510e?d=identicon)[mwkams](/maintainers/mwkams)

---

Top Contributors

[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (47 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (39 commits)")[![mwakaambrose](https://avatars.githubusercontent.com/u/8328295?v=4)](https://github.com/mwakaambrose "mwakaambrose (8 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (4 commits)")[![miclf](https://avatars.githubusercontent.com/u/3188746?v=4)](https://github.com/miclf "miclf (2 commits)")[![paulber33](https://avatars.githubusercontent.com/u/9802686?v=4)](https://github.com/paulber33 "paulber33 (2 commits)")[![riasvdv](https://avatars.githubusercontent.com/u/3626559?v=4)](https://github.com/riasvdv "riasvdv (1 commits)")

---

Tags

laravelphp8slackslacknotificationlaravelslackmwakaambroselaravel-slack-alert

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/mwakaambrose-laravel-slack-alert/health.svg)

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

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[xammie/mailbook

Laravel Mail Explorer

482458.3k1](/packages/xammie-mailbook)[spatie/laravel-notification-log

Log notifications sent by your Laravel app

207902.8k](/packages/spatie-laravel-notification-log)[wnx/laravel-sends

Keep track of outgoing emails in your Laravel application.

200427.3k](/packages/wnx-laravel-sends)[spatie/laravel-discord-alerts

Send a message to Discord

151408.0k](/packages/spatie-laravel-discord-alerts)[backstage/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24157.5k5](/packages/backstage-laravel-mails)

PHPackages © 2026

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