New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

nathanheffley/laravel-slack-blocks

Slack Blocks support for laravel notifications.
497,403 49

Larablocks Analysis

nathanheffley/laravel-slack-blocks works with any PHP project: the latest release (v2.3.0, Dec 1, 2020) doesn't depend on Laravel.

Recommendation checks

Replacement recommended

Replacement recommended: use laravel/slack-notification-channel instead. Named by its author on Packagist.

  • Marked abandoned on Packagist
  • No release in the last 12 months (last: Dec 1, 2020)
  • 3,698 downloads a month (needs 10,000)
  • 49 GitHub stars (needs 100)

State

Abandoned
  • Packagist marks this package abandoned.
  • Last stable release: Dec 1, 2020.
  • No releases in the last 12 months.
  • First released: Mar 23, 2019.
  • Monthly downloads: 3,698.
  • 1 open issue on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 3, 2026.

Install
composer require nathanheffley/laravel-slack-blocks
Latest Version:v2.3.0
PHP:^7.1.3|^8.0
License:MIT
Last Updated:Jul 18, 2023
Links: GitHub  ·  Packagist
Maintainer: nathanheffley

Laravel Slack Blocks

This package is an extension of the official laravel/slack-notification-channel package.

Note Thes core notifications package has finally built-in support for these rich Slack messages, and as such you should use the official package if you are able.

https://laravel.com/docs/10.x/notifications#formatting-slack-notifications

Usage

Instead of requiring the official package, you should require this one instead.

composer require nathanheffley/laravel-slack-blocks

Because this package is built on top of the official one, you'll have all the functionality found in the official docs.

You can follow those instructions with the slight adjustment of requiring the classes from NathanHeffley\LaravelSlackBlocks instead of Illuminate\Notifications.

Everything supported in the base Illuminate Notifications classes is supported in these extended classes.

If you want to add a block to your Slack message, you need to add the block in an attachment.

use NathanHeffley\LaravelSlackBlocks\Messages\SlackMessage;

// ...

public function toSlack($notifiable)
{
    return (new SlackMessage)
        ->attachment(function ($attachment) {
            $attachment->block(function ($block) {
                $block
                    ->type('section')
                    ->text([
                        'type' => 'mrkdwn',
                        'text' => '*Hello World!*',
                    ]);
            });
        });
}

To see all the possible fields you can add to a block, check out the official Slack Blocks documentation.

To help, some blocks have been given dedicated helper functions on the attachment model itself. Currently there are methods for adding dividers and images.

(new SlackMessage)->attachment(function ($attachment) {
    $attachment->imageBlock('http://placekitten.com/300/200', 'A cute kitten');
    $attachment->dividerBlock();
    $attachment->imageBlock('http://placekitten.com/300/200', 'A cute kitten', 'This is a titled cat image');
});

Related Packages

laravel/slack-notification-channel

Slack Notification Channel for laravel.

88,292,774 891
hampel/slack-message

Standalone implementation of Laravel's SlackMessage classes from illuminate/noti...

401 0
smcrow/laravel-slack-log

Utilizes Laravel's notifications to provide logging to slack at various levels....

3,812 9
highsolutions/laravel-poster

A Laravel package for easy Slack notifications about posts published on subscrib...

88 1
maknz/slack

A simple PHP package for sending messages to Slack, with a focus on ease of use...

12,415,289 1,156

Version History

Version Released PHP License
v2.3.0 ^7.1.3|^8.0 MIT
v2.2.2 ^7.1.3 MIT
v2.2.1 ^7.1.3 MIT
v2.2.0 ^7.1.3 MIT
v2.1.0 ^7.1.3 MIT