milpa / notifications
Channel-agnostic notification dispatch for the Milpa PHP framework: register channels (Telegram, Pushover, WebSocket, ...) and fan a payload out to recipients by "channel:recipient".
Requires
- php: >=8.3
- psr/log: ^3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.65
- milpa/core: ^0.6
- phpstan/phpdoc-parser: ^2.3
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.5
README
Milpa Notifications
Channel-agnostic notification dispatch for the Milpa PHP framework — one payload, many channels, and a failing channel never takes the others down.
Register channels (Telegram, Pushover, WebSocket, e-mail, …) and fan a single payload out to
recipients addressed as channel:recipient — or broadcast one payload to every channel. The package
owns the contracts and a default payload value object; the channels come from the host or its plugins.
Register notification channels (Telegram, Pushover, WebSocket, e-mail, …) and fan a single payload
out to recipients addressed as channel:recipient — or broadcast one payload to every channel. The
package owns the contracts (NotificationChannelInterface, NotificationPayloadInterface) and a
default payload value object; channels are supplied by the host or its plugins.
- Zero framework coupling — the only runtime dependency is PSR-3
(
psr/log) for optional logging. No ORM, no HTTP, no container. - Fail-soft — a throwing or missing channel never aborts the dispatch; each recipient gets its own boolean result and the error is logged.
Install
composer require milpa/notifications
Usage
use Milpa\Notifications\NotificationDispatcher; use Milpa\Notifications\NotificationPayload; $dispatcher = (new NotificationDispatcher($logger)) ->addChannel($telegramChannel); // implements Milpa\Notifications\Contracts\NotificationChannelInterface $payload = new NotificationPayload(type: 'alert', title: 'Deploy finished'); // Targeted: "channel:recipient" — routed to the matching channel. $dispatcher->dispatch($payload, ['telegram:123456']); // Broadcast: the same recipient id across every registered channel. $dispatcher->broadcast($payload, '123456');
Contributing
See CONTRIBUTING.md. Security reports go through SECURITY.md — privately, via GitHub Security Advisories.
License
Apache-2.0 © Rodrigo Vicente - TeamX Agency.
Milpa is designed, built, and maintained by Rodrigo Vicente - TeamX Agency.