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
Laravel Slack Blocks

Laravel Slack Blocks Laravel Package

nathanheffley/laravel-slack-blocks

A Laravel package for building Slack Block Kit messages with a fluent PHP API. Compose blocks, elements, and attachments cleanly, then send rich, interactive Slack notifications without hand-writing JSON payloads.

View on GitHub
Deep Wiki
Context7

An extension of the official laravel/slack-notification-channel package to add support for Slack Blocks.

Frequently asked questions about Laravel Slack Blocks
How do I install nathanheffley/laravel-slack-blocks?
Install it with Composer using composer require nathanheffley/laravel-slack-blocks. The package extends the official laravel/slack-notification-channel, so that dependency comes along with it. Laravel package auto-discovery means there is typically no manual service provider registration required. After installing, review the package's composer.json to confirm the PHP and Laravel constraints match your application before shipping to production.
What is the difference between this package and laravel/slack-notification-channel?
The official laravel/slack-notification-channel handles delivery of Slack notifications but gives you limited structure for message layout. This package is an extension of that channel that adds first-class support for Slack Blocks. It gives you a fluent PHP API for composing blocks, elements, and attachments instead of hand-writing Block Kit JSON. You still send messages through Laravel's normal notification system.
Do I have to write raw Slack Block Kit JSON with this package?
No. The main purpose of the package is to let you compose Block Kit payloads with a fluent PHP API. You build blocks and elements as PHP objects and pass them into your Slack message, and the package serializes them into the JSON Slack expects. This keeps payload structure readable and testable in your codebase rather than buried in string literals. You can still drop down to raw arrays if you need a block type the fluent API does not cover.
How do I send a Slack notification with blocks in Laravel?
Create a notification class as you normally would with Laravel's Slack channel, then attach your composed blocks to the Slack message instead of relying only on a plain text line. The blocks are built with the package's fluent API and rendered into the Block Kit payload at send time. Always include fallback text as well, since that is what Slack shows in notification previews and in clients that cannot render blocks. Test the rendered payload with Notification::fake before pointing it at a real workspace.
Which Laravel and PHP versions does this package support?
Version 2.3.0 of the package added PHP 8 support, which is a runtime compatibility expansion rather than a rewrite. Because PHP 8 is a version family and not a single constraint, read the php requirement in the package's composer.json directly rather than assuming 8.0, 8.1, 8.2, and 8.3 are all equally validated. The same applies to Laravel: confirm the supported Laravel majors in the composer constraints before adopting, since PHP 8 support alone says nothing about which Laravel releases are tracked.
Can I mix Slack blocks with attachments and fallback text?
Yes. Blocks are the modern layout mechanism and attachments are the legacy one, and the package lets you compose both rather than forcing a choice. In practice you should use blocks for the primary rich layout and reserve attachments for cases where you still need colored side bars or legacy formatting. Always set fallback text on the message so notification previews and older clients degrade gracefully.
How do I test Slack block notifications without hitting the Slack API?
Use Laravel's Notification::fake() and assert that the expected notification was sent to the right notifiable. From there you can inspect the Slack message object your notification builds and check the blocks it contains, so your assertions cover real payload structure rather than just the notification class name. This keeps your test suite fast and free of network calls or workspace credentials. It also gives you a reliable regression check whenever you upgrade the package.
Does this package handle Slack interactivity like buttons and modals?
The package is focused on composing outbound Block Kit payloads, so elements such as buttons and their action identifiers can be defined through the fluent API. Handling the interaction itself, meaning receiving Slack's request payload, verifying the signing secret, and responding, is application logic you own. The package is a message-building layer, not a full Slack app framework. Plan your interactive endpoint separately from the notification code.
Is nathanheffley/laravel-slack-blocks safe to use in production?
It is a small, semver-versioned package that extends an official Laravel channel, so the dependency surface is limited. The tradeoff is that it is maintained by a single author with a modest release cadence, so pin the version in composer.json and read the changelog before each upgrade. Minor releases are non-breaking by declaration, but any consumer relying on undocumented behaviour can still be affected. A short spike in a throwaway branch, running your test suite with deprecations surfaced, is a sensible gate before adoption.
What are the alternatives to using this package for Slack blocks in Laravel?
The most direct alternative is to keep using laravel/slack-notification-channel and construct the Block Kit arrays yourself, which avoids the extra dependency but puts JSON structure maintenance on your team. You could also adopt a standalone Block Kit builder library and serialize its output into the official channel, though that adds its own compatibility surface. If your Slack usage is simple, plain text notifications may be entirely sufficient. Choose based on how much of your messaging depends on rich layout.
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.
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect