waaseyaa / mercure
Mercure hub publisher for real-time SSE push in Waaseyaa
Requires
- php: >=8.5
- waaseyaa/foundation: ^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.142
- 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
- v0.1.0-alpha.113
- v0.1.0-alpha.112
- v0.1.0-alpha.111
- v0.1.0-alpha.110
- v0.1.0-alpha.63
This package is auto-updated.
Last update: 2026-09-02 16:16:38 UTC
README
Layer 0 — Foundation
Mercure hub publisher for real-time SSE push in Waaseyaa.
MercurePublisher POSTs JSON updates to a configured Mercure hub, minting a short-lived HS256 JWT (one-hour expiry) for each request. The token follows least privilege: its publish claim is scoped to the exact topic being published (publish: ['/notes/42']), never the ['*'] wildcard — so a leaked token cannot be used to publish to any other topic. The hub URL must be https://: the token is sent as a bearer header, so a non-https hub would leak it in cleartext and is therefore treated as unconfigured (the POST also pins CURLOPT_SSL_VERIFYPEER/VERIFYHOST). Publication is best-effort: when the hub URL is unconfigured/non-https or the JWT secret is unset, or the hub returns a non-2xx response, publish() returns false rather than throwing — so a failed broadcast never crashes the primary request, matching the framework convention for non-critical side effects. Pure side-effect utility — no entity storage, no global state.
Install
Ships as part of waaseyaa/framework; consumers get it via the core, cms, or full metapackage. To pull it on its own:
composer require waaseyaa/mercure
Requires PHP >= 8.5 and the cURL extension. MercureServiceProvider is auto-discovered (extra.waaseyaa.providers) and binds MercurePublisher as a container singleton, reading config['mercure']['hub_url'] and config['mercure']['jwt_secret'].
Key API
MercurePublisher (@api, final)
public function __construct(string $hubUrl, string $jwtSecret) // Publish $data (JSON-encoded) to $topic. Returns true on a 2xx hub // response; false if unconfigured, on cURL failure, or non-2xx. public function publish(string $topic, array $data): bool // True only when jwtSecret is non-empty and hubUrl is an https:// URL. public function isConfigured(): bool
MercureServiceProvider (final, extends Waaseyaa\Foundation\ServiceProvider\ServiceProvider)
Registers MercurePublisher as a singleton from the mercure config block:
public function register(): void
Usage
Resolve MercurePublisher from the container (or construct it directly) and push an update:
use Waaseyaa\Mercure\MercurePublisher; $publisher = new MercurePublisher( hubUrl: 'https://hub.example.com/.well-known/mercure', jwtSecret: 'your-hub-jwt-secret', ); if ($publisher->isConfigured()) { $publisher->publish('/notes/42', ['status' => 'updated']); }
Because publish() is best-effort, you can call it unconditionally and ignore the return value in fire-and-forget paths — an unconfigured publisher simply returns false without side effects. Guard with isConfigured() (or inspect the boolean result) when you need to know whether the broadcast was actually attempted.