Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Slack Laravel Package

jeremykenedy/slack

Laravel package for Slack integration, letting your app send messages and notifications to Slack channels, often via incoming webhooks. Useful for alerts, error logging, and activity updates from Laravel applications.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package and publish its configuration:

composer require jeremykenedy/slack
php artisan vendor:publish --tag=slack

Open config/slack.php first — that is where the webhook endpoint and any default channel/username/icon settings live. Then add the webhook URL to .env (the package reads it through the config file, so the exact key is whatever config/slack.php expects, typically something like SLACK_WEBHOOK_URL). Grab that URL from Slack under Apps → Incoming Webhooks → Add New Webhook, and treat it as a secret.

Register the facade (usually covered by package discovery, but check config/app.php aliases if you're on an older Laravel) and confirm the wiring with a one-liner:

php artisan tinker
>>> Slack::send('Hello from tinker');

If that lands in your Slack channel, you have everything you need. If not, the two failure points are almost always a cached config (php artisan config:clear) or a webhook pointed at a channel you no longer have access to.

Your first real use case should be the simplest one: notify a channel when something operationally interesting happens — a new order, a failed import, a support form submission.

Implementation Patterns

Wrap sends in your own service. This package is a thin webhook client; don't sprinkle Slack::send() calls through controllers. Put one App\Services\SlackNotifier in front of it so you can swap in laravel/slack-notification-channel or raw Http::post() later without touching call sites.

class SlackNotifier
{
    public function alert(string $message, array $context = []): void
    {
        try {
            Slack::send($message.' '.json_encode($context));
        } catch (\Throwable $e) {
            Log::warning('Slack alert failed', ['error' => $e->getMessage()]);
        }
    }
}

Push sends off the request path. Slack webhooks are external HTTP calls; a slow or rate-limited endpoint shouldn't add latency to a user's request. Either dispatch a queued job or use dispatchAfterResponse():

dispatch(function () use ($order) {
    app(SlackNotifier::class)->alert("New order ##{$order->id} — \${$order->total}");
})->afterResponse();

Feed the exception handler. Hook into App\Exceptions\Handler::report() (or bootstrap/app.php with the new exception API) so unhandled exceptions hit an #errors channel. Gate it on app()->isProduction() so local debugging doesn't spam the team.

Use it for scheduled-task heartbeats. A $schedule->call() or a small artisan command that pings Slack when a nightly job finishes (or doesn't finish) is the highest-value, lowest-effort use of a package like this.

Multiple destinations. If the config supports per-call overrides (webhook/channel), keep named webhooks in config/slack.php — #deployments, #alerts, #sales — and route by key. If it only supports a single global webhook, create separate notifier instances configured from env or read additional webhook URLs from your own config file.

Testing. Stub the underlying HTTP layer with Http::fake() rather than mocking the facade, and assert on the outgoing request payload. Alternatively bind a fake SlackNotifier into the container in TestCase::setUp().

Gotchas and Tips

  • Maintenance risk is the headline. Last release was December 2020 and the package has very low adoption. Before committing, verify composer.json constraints against your Laravel version; expect to need --ignore-platform-reqs or a repositories fork on Laravel 10/11. Budget time to vendor the ~100 lines of code or replace it with laravel/slack-notification-channel.
  • Webhook URLs are bearer credentials. Anyone with the URL can post to the channel. Keep it in .env, never in config/slack.php committed to git, and rotate it if it leaks. Incoming webhooks are also bound to one channel at creation time — you generally cannot retarget them per message.
  • Config cache bites. After changing the webhook in .env on a deployed environment, run php artisan config:cache (or config:clear). A stale cached config is the most common "it works locally" bug with this class of package.
  • Slack limits are real. Text messages cap around 4,000 characters and Block Kit payloads at 50 blocks. Webhooks are rate-limited to roughly one message per second per webhook; a busy loop will get you 429s. Batch or throttle noisy alerts.
  • Failures may be silent. If the package swallows non-2xx responses, you'll only find out when someone notices the channel is quiet. Always wrap sends in try/catch and log the response body — Slack returns a useful invalid_payload or channel_not_found message.
  • Markdown ≠ Slack mrkdwn. **bold** renders literally; Slack wants *bold*, and links are <https://example.com|label>. Escape user-supplied content before embedding it in messages, or a stray < will mangle the layout.
  • Guard non-production. Wrap the notifier in an environment check or a SLACK_ENABLED=false flag, otherwise every local test run pings the team channel.
  • Extension point: if you keep the package, the cleanest move is one adapter class implementing a Notifier interface, bound in a service provider. That interface is your escape hatch when the package stops working on a future Laravel release.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core