PHPackages                             airondev/laravel-slack-alerts - 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. airondev/laravel-slack-alerts

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

airondev/laravel-slack-alerts
=============================

Send a message to Slack

01PHP

Since Apr 10Pushed 3y ago1 watchersCompare

[ Source](https://github.com/AironDev/laravel-slack-alerts)[ Packagist](https://packagist.org/packages/airondev/laravel-slack-alerts)[ RSS](/packages/airondev-laravel-slack-alerts/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

[![](https://camo.githubusercontent.com/2bedf63f24cda7efab02da955dc11fb7ef8a060e2f26b73c33a7aac84529b8a3/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f737570706f72742d756b7261696e652e7376673f743d31)](https://supportukrainenow.org)

Quickly send a message to Slack
===============================

[](#quickly-send-a-message-to-slack)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0c50838678c29b0d50eb6862ee89f57e6c0a513d6257327bad071d99bc151aef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d736c61636b2d616c657274732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-slack-alerts)[![run-tests](https://github.com/spatie/laravel-slack-alerts/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/laravel-slack-alerts/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/spatie/laravel-slack-alerts/actions/workflows/phpstan.yml/badge.svg)](https://github.com/spatie/laravel-slack-alerts/actions/workflows/phpstan.yml)[![Check & fix styling](https://github.com/spatie/laravel-slack-alerts/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/spatie/laravel-slack-alerts/actions/workflows/php-cs-fixer.yml)[![Total Downloads](https://camo.githubusercontent.com/abfdb928b3b3cb5e68f4196b2f247da82add4fafff57019e962dea26e6ac04bd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d736c61636b2d616c657274732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-slack-alerts)

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

```
use Spatie\SlackAlerts\Facades\SlackAlert;

SlackAlert::message("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.

Want to send alerts to Discord instead? Check out [laravel-discord-alerts](https://github.com/spatie/laravel-discord-alerts).

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/ca8fd9d46f6e6e0e8ffe9cecb3237fd19cf9b38dba85700f49caaa1ba7eb4feb/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f6c61726176656c2d736c61636b2d616c657274732e6a70673f743d31)](https://spatie.be/github-ad-click/laravel-slack-alerts)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require spatie/laravel-slack-alerts
```

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-alerts-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'),
    ],

    /*
     * This job will send the message to Slack. You can extend this
     * job to set timeouts, retries, etc...
     */
    'job' => Spatie\SlackAlerts\Jobs\SendToSlackChannelJob::class,
];
```

Usage
-----

[](#usage)

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

```
SlackAlert::message("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-alerts.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 Spatie\SlackAlerts\Facades\SlackAlert;

SlackAlert::to('marketing')->message("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 Spatie\SlackAlerts\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 Spatie\SlackAlerts\Facades\SlackAlert;

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

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

```
SlackAlert::message("");
```

### Emoji's

[](#emojis)

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

```
use Spatie\SlackAlerts\Facades\SlackAlert;

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

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [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.

Alternatives
------------

[](#alternatives)

If you want to send rich messages with Block Kit, we suggest using [slack-php/slack-php-block-kit](https://github.com/slack-php/slack-php-block-kit)

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29748407?v=4)[Aniebiet Aaron ](/maintainers/AironDev)[@AironDev](https://github.com/AironDev)

---

Top Contributors

[![AironDev](https://avatars.githubusercontent.com/u/29748407?v=4)](https://github.com/AironDev "AironDev (14 commits)")

### Embed Badge

![Health badge](/badges/airondev-laravel-slack-alerts/health.svg)

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

###  Alternatives

[maize-tech/laravel-email-domain-rule

Laravel Email Domain Rule

612.0k](/packages/maize-tech-laravel-email-domain-rule)[sarfraznawaz2005/noty

Laravel package to incorporate noty flash notifications into laravel.

324.5k](/packages/sarfraznawaz2005-noty)

PHPackages © 2026

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