PHPackages                             labrodev/laravel-slack - 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. [API Development](/categories/api)
4. /
5. labrodev/laravel-slack

ActiveLibrary[API Development](/categories/api)

labrodev/laravel-slack
======================

Stateless Slack incoming-webhook client for Laravel with Block Kit message transport and webhook-URL validation.

v1.0.0(yesterday)08↑2525%MITPHP ^8.4

Since Jul 22Compare

[ Source](https://github.com/labrodev/laravel-slack)[ Packagist](https://packagist.org/packages/labrodev/laravel-slack)[ Docs](https://github.com/labrodev/laravel-slack)[ RSS](/packages/labrodev-laravel-slack/feed)WikiDiscussions Synced today

READMEChangelogDependencies (9)Versions (2)Used By (0)

Laravel Slack
=============

[](#laravel-slack)

Stateless Slack incoming-webhook client for Laravel with Block Kit message transport and webhook-URL validation. Slack incoming webhooks are self-contained bearer URLs — there is no OAuth flow, no bot token, and no app-level credential to configure. Each caller supplies its own webhook URL on every call, and the package stores nothing.

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

[](#installation)

```
composer require labrodev/laravel-slack
```

Optionally publish the config file:

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

```
SLACK_HTTP_TIMEOUT=10
SLACK_WEBHOOK_HOST=hooks.slack.com
SLACK_WEBHOOK_PATH_PREFIX=/services/
```

`SLACK_WEBHOOK_HOST` and `SLACK_WEBHOOK_PATH_PREFIX` only need overriding if Slack ever changes its incoming-webhook domain or path shape — the defaults match Slack's current URLs.

Sending a message
-----------------

[](#sending-a-message)

`SlackClient::send()` posts [Block Kit](https://api.slack.com/block-kit) blocks and a fallback text to the incoming-webhook URL you provide:

```
use Labrodev\Slack\Services\SlackClient;
use Labrodev\Slack\Exceptions\SlackRequestFailed;
use Labrodev\Slack\Exceptions\SlackWebhookRevoked;

$slackClient = new SlackClient();

$blocks = [
    [
        'type' => 'section',
        'text' => [
            'type' => 'mrkdwn',
            'text' => 'A new incident was reported.',
        ],
    ],
];

try {
    $slackClient->send(
        webhookUrl: $webhookUrl,
        blocks: $blocks,
        fallbackText: 'A new incident was reported.',
    );
} catch (SlackWebhookRevoked) {
    // the webhook was deleted or revoked on Slack's side
} catch (SlackRequestFailed) {
    // any other failed request
}
```

Validating a webhook URL
------------------------

[](#validating-a-webhook-url)

Use `SlackWebhookUrl::validate()` to check a pasted webhook URL before storing it. It checks the scheme, the host against `slack.webhook_host`, and the path against `slack.webhook_path_prefix`, without overfitting to the exact segment count — and throws a specific exception for whichever part failed:

```
use Labrodev\Slack\Support\SlackWebhookUrl;
use Labrodev\Slack\Exceptions\SlackWebhookUrlSchemeInvalid;
use Labrodev\Slack\Exceptions\SlackWebhookUrlHostInvalid;
use Labrodev\Slack\Exceptions\SlackWebhookUrlPathInvalid;

try {
    new SlackWebhookUrl()->validate($request->input('webhook_url'));
} catch (SlackWebhookUrlSchemeInvalid|SlackWebhookUrlHostInvalid|SlackWebhookUrlPathInvalid) {
    throw ValidationException::withMessages([
        'webhook_url' => 'That does not look like a Slack incoming-webhook URL.',
    ]);
}
```

Detecting a revoked webhook
---------------------------

[](#detecting-a-revoked-webhook)

Catch `SlackWebhookRevoked` to mark a stored webhook credential as dead instead of retrying it indefinitely:

```
use Labrodev\Slack\Exceptions\SlackWebhookRevoked;

try {
    $slackClient->send(webhookUrl: $channel->webhook_url, blocks: $blocks, fallbackText: $fallbackText);
} catch (SlackWebhookRevoked) {
    $channel->update(['webhook_url' => null]);
}
```

Exceptions
----------

[](#exceptions)

- `Labrodev\Slack\Exceptions\SlackWebhookRevoked` — Slack returned `404` or `410`: the webhook was deleted or revoked.
- `Labrodev\Slack\Exceptions\SlackRequestFailed` — any other failed request.
- `Labrodev\Slack\Exceptions\SlackWebhookUrlSchemeInvalid` — thrown by `SlackWebhookUrl::validate()` when the scheme isn't `https`.
- `Labrodev\Slack\Exceptions\SlackWebhookUrlHostInvalid` — thrown by `SlackWebhookUrl::validate()` when the host doesn't match `slack.webhook_host`.
- `Labrodev\Slack\Exceptions\SlackWebhookUrlPathInvalid` — thrown by `SlackWebhookUrl::validate()` when the path doesn't start with `slack.webhook_path_prefix`.

All carry fixed messages only. A Slack incoming-webhook URL is the bearer secret itself, so it is never interpolated into an exception message.

Testing
-------

[](#testing)

```
composer test      # pest
composer phpstan   # larastan, level 7
composer pint      # laravel preset
composer check     # all of the above
```

License
-------

[](#license)

MIT. See [LICENSE.md](LICENSE.md).

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance100

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

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

1d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/151143718?v=4)[Lashyn Petro ](/maintainers/labrodev)[@labrodev](https://github.com/labrodev)

---

Tags

apiclientlaravelslackwebhooklabrodev

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5022.6k](/packages/simplestats-io-laravel-client)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

813336.8k3](/packages/defstudio-telegraph)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

293.1k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

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