laravel/slack-notification-channel
Official Laravel notification channel for sending messages to Slack. Integrates with the Notifications system to deliver alerts and updates via Slack, with support for rich message formatting. Includes tests, security policy, and MIT license.
Notification facade. This ensures consistency with existing notification patterns (e.g., User::notify(new SlackAlert($data))), reducing cognitive load for developers.Notifiable::sent, Notifiable::failed), enabling observability and retries out of the box.SlackWebhookChannel, reducing dependency on legacy attachment formats.laravel/slack-notification-channel).from name/icon).SlackMessage or SlackWebhookMessage.buildJsonPayload exposed in v3.0+).queue:work) and implement exponential backoff in custom failure handlers.OAuth or Signing Secret). The package does not enforce this; TPM must ensure secure configuration.getBlockKitBuilderUrl() helper.error channel, Laravel logs)?maxAttempts in Notification class)?Guzzle overrides) be needed for non-standard APIs?Mail, Nexmo) without duplication.fake() or Mockery for unit tests.Http::post calls to Slack).SlackMessage for simple text/attachments; SlackWebhookMessage for BlockKit.Notification::route().guzzlehttp/guzzle (injected via Laravel’s DI container).spatie/laravel-slack)..env:
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...
SLACK_FROM=MyAppBot
php artisan vendor:publish --provider="Laravel\SlackNotificationChannel\SlackNotificationChannelServiceProvider"
SlackMessage:
use Laravel\SlackNotificationChannel\SlackMessage;
class AlertSlackNotification extends SlackMessage
{
public function toSlack($notifiable)
{
return [
'text' => 'New alert: ' . $this->alert->message,
'attachments' => [
// Legacy format (deprecated)
],
// OR BlockKit:
'blocks' => [
['type' => 'section', 'text' => ['type' => 'mrkdwn', 'text' => 'Alert!']],
],
];
}
}
$user->routeNotificationsTo(['slack' => 'U123ABC']);
// OR for channels:
Notification::route('slack', '#general')->notify(new AlertSlackNotification($alert));
fake() to mock Slack responses:
Notification::fake();
$user->notify(new AlertSlackNotification($alert));
Notification::assertSentTo($user, AlertSlackNotification::class);
composer update laravel/slack-notification-channel. Monitor changelog for breaking changes (e.g., Slack API deprecations).guzzlehttp/guzzle is managed by Laravel; no manual updates needed.storage/logs/laravel.log) and Slack’s API error responses.FailedNotification handler.How can I help you explore Laravel packages today?