SlackChannel
in package
implements
NotificationChannelInterface
FinalYes
Posts to a Slack incoming webhook URL.
The HTTP send is injected as a callable so callers can supply their own client (PSR-18, Guzzle, a stub for tests). The default implementation uses stream_context_create + file_get_contents and requires no PHP extensions beyond the core.
The webhook URL is a constructor parameter; never hardcode a webhook in source.
Table of Contents
Interfaces
- NotificationChannelInterface
- A delivery mechanism for notifications. Implementations should swallow transient delivery errors rather than propagating them; the pipeline must not crash because Slack is down.
Methods
- __construct() : mixed
- name() : string
- Stable identifier for routing or filtering (e.g., "slack", "email", "log").
- send() : void
Methods
__construct()
public
__construct(string $webhookUrl[, string $name = 'slack' ][, string|null $username = null ][, string|null $iconEmoji = null ][, callable(string, array<int, string>, string): void|null $httpClient = null ]) : mixed
Parameters
- $webhookUrl : string
-
Slack incoming webhook URL.
- $name : string = 'slack'
-
Channel identifier used by routing/filtering.
- $username : string|null = null
-
Optional username override.
- $iconEmoji : string|null = null
-
Optional emoji override (e.g. ":warning:").
- $httpClient : callable(string, array<int, string>, string): void|null = null
name()
Stable identifier for routing or filtering (e.g., "slack", "email", "log").
public
name() : string
Attributes
- #[Override]
Return values
stringsend()
public
send(Notification $notification) : void
Parameters
- $notification : Notification
Attributes
- #[Override]