systonia / waypoint-flash
Flash messages for Waypoint: queue a message, redirect, show it once on the next page -- with or without JavaScript.
v1.1.1
2026-10-11 20:55 UTC
Requires
- php: >=8.5
- systonia/waypoint: ^1.5.4
Requires (Dev)
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^13.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Flash messages for Waypoint: queue a message, redirect, and it is shown once on
the next page. Works without JavaScript; with waypoint.js it also auto-hides and can be dismissed
in place.
Setup
$app->plugin(new Waypoint\Flash\FlashPlugin()); // before attach()
In the layout:
<body>
<?= $this->flashes() ?>
<main><?= $content ?></main>
<?= $this->pluginAssetTags() ?>
Usage
#[Inject] private Waypoint\Flash\Flash $flash; $this->flash->success('Profile updated.'); // also info(), warning(), error() return new Redirect('/profile');
A message queued while rendering a page (no redirect) is shown on that page. Text is escaped; messages carry no HTML.
How it works
- Queued messages travel in the
flashcookie (base64url JSON, signed withCsrfOptions::$secretwhen configured); the next rendered page reads it and clears it. $this->flashes()renders<div class="wp-flashes" aria-live="polite">with one block per message:role="status", orrole="alert"for errors, plus a real dismiss form.- Without JavaScript the dismiss button posts to
/flash/dismiss, which drops pending messages and returns to the referring page. With JavaScriptflash.jsremoves the message in place, hides non-error messages aftertimeout, and moves focus to an error.
Options
| Setting | Default | Description |
|---|---|---|
cookieName |
'flash' |
Cookie carrying queued messages. |
ttl |
120 |
Seconds an unread message survives. |
cookieSecure |
true |
Cookie Secure attribute; false for HTTP-only local dev. |
dismissPath |
'/flash/dismiss' |
The no-JS dismiss endpoint. |
timeout |
6000 |
Milliseconds until the client hides a message; 0 keeps it. Errors always stay. |
dismissLabel |
'Dismiss' |
aria-label of the dismiss button. |
Development
composer install && composer test && composer stan
License
MIT or Apache-2.0, at your option.