waaseyaa / notification
Multi-channel notification system for Waaseyaa
Requires
- php: >=8.5
- waaseyaa/database-legacy: ^0.1.0-alpha.300
- waaseyaa/foundation: ^0.1.0-alpha.300
- waaseyaa/mail: ^0.1.0-alpha.300
- waaseyaa/queue: ^0.1.0-alpha.300
Requires (Dev)
- phpunit/phpunit: ^13.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- dev-main / 0.1.x-dev
- v0.1.0-alpha.300
- v0.1.0-alpha.299
- v0.1.0-alpha.298
- v0.1.0-alpha.297
- v0.1.0-alpha.296
- v0.1.0-alpha.295
- v0.1.0-alpha.294
- v0.1.0-alpha.293
- v0.1.0-alpha.292
- v0.1.0-alpha.291
- v0.1.0-alpha.290
- v0.1.0-alpha.289
- v0.1.0-alpha.288
- v0.1.0-alpha.287
- v0.1.0-alpha.286
- v0.1.0-alpha.285
- v0.1.0-alpha.284
- v0.1.0-alpha.283
- v0.1.0-alpha.282
- v0.1.0-alpha.281
- v0.1.0-alpha.280
- v0.1.0-alpha.279
- v0.1.0-alpha.278
- v0.1.0-alpha.277
- v0.1.0-alpha.276
- v0.1.0-alpha.275
- v0.1.0-alpha.274
- v0.1.0-alpha.273
- v0.1.0-alpha.272
- v0.1.0-alpha.271
- v0.1.0-alpha.270
- v0.1.0-alpha.269
- v0.1.0-alpha.268
- v0.1.0-alpha.267
- v0.1.0-alpha.266
- v0.1.0-alpha.265
- v0.1.0-alpha.264
- v0.1.0-alpha.263
- v0.1.0-alpha.262
- v0.1.0-alpha.261
- v0.1.0-alpha.260
- v0.1.0-alpha.259
- v0.1.0-alpha.258
- v0.1.0-alpha.257
- v0.1.0-alpha.256
- v0.1.0-alpha.255
- v0.1.0-alpha.254
- v0.1.0-alpha.253
- v0.1.0-alpha.252
- v0.1.0-alpha.251
- v0.1.0-alpha.250
- v0.1.0-alpha.249
- v0.1.0-alpha.248
- v0.1.0-alpha.247
- v0.1.0-alpha.246
- v0.1.0-alpha.245
- v0.1.0-alpha.244
- v0.1.0-alpha.243
- v0.1.0-alpha.242
- v0.1.0-alpha.241
- v0.1.0-alpha.240
- v0.1.0-alpha.239
- v0.1.0-alpha.238
- v0.1.0-alpha.237
- v0.1.0-alpha.236
- v0.1.0-alpha.235
- v0.1.0-alpha.234
- v0.1.0-alpha.233
- v0.1.0-alpha.232
- v0.1.0-alpha.231
- v0.1.0-alpha.230
- v0.1.0-alpha.229
- v0.1.0-alpha.228
- v0.1.0-alpha.227
- v0.1.0-alpha.226
- v0.1.0-alpha.225
- v0.1.0-alpha.224
- v0.1.0-alpha.223
- v0.1.0-alpha.222
- v0.1.0-alpha.221
- v0.1.0-alpha.220
- v0.1.0-alpha.219
- v0.1.0-alpha.218
- v0.1.0-alpha.217
- v0.1.0-alpha.216
- v0.1.0-alpha.215
- v0.1.0-alpha.214
- v0.1.0-alpha.213
- v0.1.0-alpha.212
- v0.1.0-alpha.211
- v0.1.0-alpha.210
- v0.1.0-alpha.209
- v0.1.0-alpha.208
- v0.1.0-alpha.207
- v0.1.0-alpha.206
- v0.1.0-alpha.205
- v0.1.0-alpha.204
- v0.1.0-alpha.203
- v0.1.0-alpha.202
- v0.1.0-alpha.201
- v0.1.0-alpha.200
- v0.1.0-alpha.199
- v0.1.0-alpha.198
- v0.1.0-alpha.197
- v0.1.0-alpha.196
- v0.1.0-alpha.195
- v0.1.0-alpha.194
- v0.1.0-alpha.193
- v0.1.0-alpha.192
- v0.1.0-alpha.191
- v0.1.0-alpha.190
- v0.1.0-alpha.189
- v0.1.0-alpha.188
- v0.1.0-alpha.187
- v0.1.0-alpha.186
- v0.1.0-alpha.185
- v0.1.0-alpha.184
- v0.1.0-alpha.183
- v0.1.0-alpha.182
- v0.1.0-alpha.181
- v0.1.0-alpha.180
- v0.1.0-alpha.179
- v0.1.0-alpha.178
- v0.1.0-alpha.177
- v0.1.0-alpha.176
- v0.1.0-alpha.175
- v0.1.0-alpha.174
- v0.1.0-alpha.173
- v0.1.0-alpha.172
- v0.1.0-alpha.171
- v0.1.0-alpha.170
- v0.1.0-alpha.169
- v0.1.0-alpha.168
- v0.1.0-alpha.167
- v0.1.0-alpha.166
- v0.1.0-alpha.165
- v0.1.0-alpha.164
- v0.1.0-alpha.163
- v0.1.0-alpha.162
- v0.1.0-alpha.161
- v0.1.0-alpha.160
- v0.1.0-alpha.159
- v0.1.0-alpha.158
- v0.1.0-alpha.157
- v0.1.0-alpha.156
- v0.1.0-alpha.155
- v0.1.0-alpha.154
- v0.1.0-alpha.153
- v0.1.0-alpha.152
- v0.1.0-alpha.151
- v0.1.0-alpha.150
- v0.1.0-alpha.149
- v0.1.0-alpha.148
- v0.1.0-alpha.147
- v0.1.0-alpha.146
- v0.1.0-alpha.145
- v0.1.0-alpha.144
- v0.1.0-alpha.143
- v0.1.0-alpha.141
- v0.1.0-alpha.140
- v0.1.0-alpha.139
- v0.1.0-alpha.138
- v0.1.0-alpha.137
- v0.1.0-alpha.136
- v0.1.0-alpha.135
- v0.1.0-alpha.134
- v0.1.0-alpha.133
- v0.1.0-alpha.132
- v0.1.0-alpha.131
- v0.1.0-alpha.130
- v0.1.0-alpha.129
- v0.1.0-alpha.128
- v0.1.0-alpha.127
- v0.1.0-alpha.126
- v0.1.0-alpha.125
- v0.1.0-alpha.124
- v0.1.0-alpha.123
- v0.1.0-alpha.122
- v0.1.0-alpha.121
- v0.1.0-alpha.120
- v0.1.0-alpha.119
- v0.1.0-alpha.118
- v0.1.0-alpha.117
- v0.1.0-alpha.116
- v0.1.0-alpha.115
- v0.1.0-alpha.114
This package is auto-updated.
Last update: 2026-09-02 16:17:03 UTC
README
Layer 3 — Services
Multi-channel notification system for Waaseyaa. A NotificationInterface declares which channels it targets (via()) and how it renders for each (toMail(), toDatabase(), …); a NotifiableInterface recipient supplies its per-channel routing (email address, database id). NotificationDispatcher fans a notification out across the matching ChannelInterface implementations — synchronously, or queued via the framework Job system so user-facing requests never wait on email or persistence. Channel delivery is best-effort: a single channel throwing is logged, not propagated.
Install
Ships as part of waaseyaa/framework — consumers on the core/cms/full metapackages already have it. To pull it on its own:
composer require waaseyaa/notification
The package self-registers NotificationServiceProvider (via extra.waaseyaa.providers), which binds NotificationDispatcher as a singleton and assembles the mail and database channels from whatever MailerInterface / DatabaseInterface are configured.
Key API
interface NotificationInterface { /** @return list<string> channel names, e.g. ['mail', 'database'] */ public function via(NotifiableInterface $notifiable): array; /** @return array<string, mixed> */ public function toArray(NotifiableInterface $notifiable): array; // Optional, resolved by channels via method_exists(): // toMail(NotifiableInterface): \Waaseyaa\Mail\Envelope // toDatabase(NotifiableInterface): array<string, mixed> } interface NotifiableInterface // @api { public function routeNotificationFor(string $channel): mixed; // 'mail' => email, 'database' => id public function getNotifiableId(): string; public function getNotifiableType(): string; } interface ChannelInterface { public function send(NotifiableInterface $notifiable, NotificationInterface $notification): void; } final class NotificationDispatcher // @api { /** @param array<string, ChannelInterface> $channels */ public function __construct(QueueInterface $queue, array $channels, ?LoggerInterface $logger = null); public function send(NotifiableInterface $notifiable, NotificationInterface $notification): void; // sync public function sendAsync(NotifiableInterface $notifiable, NotificationInterface $notification): void; // queued /** @param iterable<NotifiableInterface> $notifiables */ public function sendToMany(iterable $notifiables, NotificationInterface $notification): void; /** @return array<string, ChannelInterface> */ public function channels(): array; }
Helpers: NotifiableTrait (@api) implements NotifiableInterface for any class exposing get()/id()/getEntityTypeId() (e.g. EntityBase subclasses); DefaultNotifiable is a standalone implementation for apps and tests. Built-in channels: Channel\MailChannel, Channel\DatabaseChannel (persists to waaseyaa_notifications). Async delivery uses Job\SendNotificationJob.
Usage
use Waaseyaa\Notification\{NotifiableInterface, NotificationInterface, NotificationDispatcher}; use Waaseyaa\Notification\Channel\MailChannel; use Waaseyaa\Mail\{Envelope, Mailer}; use Waaseyaa\Queue\SyncQueue; $notification = new class implements NotificationInterface { public function via(NotifiableInterface $n): array { return ['mail']; } public function toArray(NotifiableInterface $n): array { return ['message' => 'Welcome']; } public function toMail(NotifiableInterface $n): Envelope { return new Envelope( to: [$n->routeNotificationFor('mail')], from: 'noreply@example.com', subject: 'Welcome', textBody: 'Thanks for joining.', ); } }; $dispatcher = new NotificationDispatcher( new SyncQueue(), ['mail' => new MailChannel($mailer)], ); $dispatcher->send($user, $notification); // $user implements NotifiableInterface
Resolve NotificationDispatcher from the container instead of constructing it by hand once the service provider is booted; call sendAsync() to queue delivery for the worker.