laravel/slack-notification-channel
Official Laravel notification channel for sending notifications to Slack. Integrates with Laravel’s Notifications system, letting you route messages to Slack channels or users and customize payloads. See Laravel docs for configuration and usage.
Notification system, requiring minimal architectural changes. Aligns with Laravel’s channel-based notification pattern (e.g., Mail, Nexmo), reducing cognitive load for developers.SlackChannel (legacy, attachment-based messages).SlackWebhookChannel (modern, BlockKit/WebAPI-based, recommended for new implementations).notifiable:reminding) and queues (via shouldQueue()), enabling async Slack notifications.laravel/slack-notification-channel).config/services.php.SlackMessage to modify payloads (e.g., add custom fields).buildJsonPayload() for advanced BlockKit structures.| Risk Area | Mitigation Strategy |
|---|---|
| Slack API Deprecations | Monitor Slack’s API changelog and update the package (MIT license allows forks if needed). |
| BlockKit Migration | Start with SlackWebhookChannel (v3.6+) for new features; deprecate legacy SlackChannel gradually. |
| Rate Limiting | Implement exponential backoff in custom channel logic or use Slack’s retry headers. |
| Security | Store Slack tokens in Laravel’s env() (never hardcode). Use IAM roles for Slack apps in production. |
| PHP/Laravel Version Lock | Pin to ^3.8 for Laravel 13 support; test downgrades if using older versions. |
SlackWebhookChannel + BlockKit.Illuminate\Notifications\Notification interface.shouldQueue() for async delivery (uses Laravel’s queue system).Event::dispatch() or notify() methods.SlackWebhookChannel (lower latency, no OAuth refresh).SlackChannel (legacy) or interactive features (e.g., users_select).Mail, Database) to identify Slack candidates.User, Team).SlackWebhookChannel.use Illuminate\Notifications\Messages\SlackMessage;
use Laravel\SlackNotificationChannel\SlackWebhookChannel;
class DeploymentAlert implements ShouldQueue
{
public function via($notifiable)
{
return [new SlackWebhookChannel];
}
public function toSlack($notifiable)
{
return (new SlackMessage)
->content("Deployment failed: {$this->job->url}")
->attachment(function ($attachment) {
$attachment->title('Error Details')
->field('Status', 'Failed', true)
->field('Environment', $this->job->env)
->footer('Check logs at ' . config('app.url'));
});
}
}
SlackChannel with SlackWebhookChannel for new features.SlackChannel for existing attachments-based messages until fully migrated.| Component | Compatibility Notes |
|---|---|
| Laravel 10–13 | Fully supported (v3.x). Use ^3.8 for Laravel 13. |
| PHP 8.1–8.4 | Tested; v3.4+ includes PHP 8.4 deprecation warnings. |
| Slack API | Supports BlockKit (v3.6+) and legacy attachments. Check Slack’s API docs for breaking changes. |
| Third-Party Packages | No conflicts detected. Guzzle is Laravel’s default HTTP client. |
SLACK_WEBHOOK_URL to .env.php artisan vendor:publish --provider="Laravel\SlackNotificationChannel\SlackNotificationChannelServiceProvider").SlackWebhookChannel for critical notifications (e.g., errors, alerts).users_select, buttons) via SlackMessage extensions.try-catch in channel logic).config/services.php to avoid hardcoding.SLACK_BOT_TOKEN).SlackChannel in favor of SlackWebhookChannel within 6–12 months..env.buildJsonPayload().tap() to inspect Slack messages before sending:
$message->toSlack($notifiable)->tap(function ($message) {
Log::debug('Slack payload:', $message->toArray());
});
channel_not_found, invalid_auth).shouldQueue()) to offload Slack API calls.How can I help you explore Laravel packages today?