Repository navigation
API Notify
Caligrafy Quill 2.26.0. Generated from the source by
php qa/build-api-reference.php; the guides explain how to use these classes, this reference says exactly what each public method takes and returns. Back to the API reference.
Part of Jobs, notifications and mail.
namespace Caligrafy;
class NotifySource: framework/core/Notify.php:28
Class Notify Notify::user($userId, ['title' => ..., 'body' => ..., 'url' => ..., 'tag' => ..., 'urgency' => ...]) sends to every channel the user turned on and logs the result (caligrafy_notifications: never the body; kept 30 days):
- push: each browser the user subscribed (caligrafy_push_subscriptions), with the VAPID keys of .env (php caligrafer.php notify keys), 5 seconds per push service, the message kept 24 hours for a device that is off; a 404 or 410 deletes the subscription, so do 5 failures in a row
- email: the user's confirmed address only (caligrafy_notify_emails), through MAIL_*, with a one-click unsubscribe link (a signed URL) and the List-Unsubscribe headers
A delivery failure never throws; a bad message throws ServiceError::invalid. At most NOTIFY_RATE_PER_HOUR messages per user and hour (30): above it nothing is sent ('skipped' => 'rate'). In-page alerts stay the app's job. Without the tables (php caligrafer.php platform install) nothing is sent and nothing fails.
CHANNELS = array('push', 'email')SUBSCRIPTIONS = 'caligrafy_push_subscriptions'EMAILS = 'caligrafy_notify_emails'PREFS = 'caligrafy_notify_prefs'LOG = 'caligrafy_notifications'TTL = 86400PUSH_TIMEOUT = 5MAX_FAILURES = 5PAYLOAD_BYTES = 3072TOKEN_HOURS = 24KEEP_DAYS = 30
-
public static $pushSender = null: callable|null replaces the push sender in tests: fn(array $subscriptions, string $payload, array $options) => [endpoint => status] -
public static $mailSender = null: callable|null replaces the mail sender in tests: fn($to, $subject, $html, array $headers) => bool
Notify::user()Notify::forget()Notify::message()Notify::pushConfigured()Notify::keys()Notify::subscribe()Notify::unsubscribe()Notify::emailConfigured()Notify::setEmail()Notify::confirm()Notify::unsubscribeUrl()Notify::unsubscribeEmail()Notify::html()Notify::theme()Notify::page()Notify::offered()Notify::prefer()Notify::enabled()Notify::status()Notify::base()
public static function user($userId, array $message)Sends a message to a user on every channel they turned on
Parameters
-
$userIdint|string: the id Context::userId() returns -
$messagearray: title (80), body (300), url (https or a path of the app), tag, urgency (low, normal, high)
Returns array: push (how many browsers got it), email (whether it was sent), skipped (null, or 'rate')
- @throws ServiceError invalid, on a bad message
Source: framework/core/Notify.php:58
public static function forget($userId)Deletes everything notifications keep about a user (their subscriptions, address, choices and log): call it when you delete the user
Parameters
$userId
Source: framework/core/Notify.php:90
public static function message(array $message)The message, checked and completed (urgency normal)
Parameters
-
$messagearray -
@throws ServiceError invalid
Source: framework/core/Notify.php:101
public static function pushConfigured()Whether the VAPID keys are set (php caligrafer.php notify keys)
Source: framework/core/Notify.php:124
public static function keys()A new pair of VAPID keys (base64url): public and private
Source: framework/core/Notify.php:132
public static function subscribe($userId, array $subscription, $userAgent = '')Saves a browser's push subscription (the JSON of PushSubscription) for a user; an endpoint belongs to one user
Parameters
$userId-
$subscriptionarray -
$userAgent, default''
Source: framework/core/Notify.php:142
public static function unsubscribe($userId, $endpoint)Deletes one of the user's subscriptions (only theirs): whether one was deleted
Parameters
$userId$endpoint
Source: framework/core/Notify.php:163
public static function emailConfigured()Whether email can be sent: MAIL_HOST set and an address for the app's links (APP_URL, or a web request)
Source: framework/core/Notify.php:226
public static function setEmail($userId, $email)Sets the user's address (one per user) and emails the confirmation link: valid 24 hours, used once
Parameters
$userId$email
Returns array: the address, and whether the link was sent
Source: framework/core/Notify.php:236
public static function confirm($token)Confirms an address from its link: the user id, or null when the link is unknown, used or expired
Parameters
$token
Source: framework/core/Notify.php:255
public static function unsubscribeUrl($userId)The one-click unsubscribe link of a user's emails (signed with APP_KEY)
Parameters
$userId
Source: framework/core/Notify.php:269
public static function unsubscribeEmail($userId, $signature)Turns the user's emails off from a signed link: whether the signature was right
Parameters
$userId$signature
Source: framework/core/Notify.php:277
public static function html($title, array $paragraphs, $button, $footer, $code = null)An email in the app's look: the colors, font and corners of its design style (DESIGN_STYLE), else Caligrafy's, written inline since email clients ignore stylesheets. $code: a code to type (shown large), $footer: the last line
Parameters
$title-
$paragraphsarray $button$footer-
$code, defaultnull
Source: framework/core/Notify.php:321
public static function theme($public = null)The look of the app's emails: Caligrafy's (public/css/look.css), with the design style of DESIGN_STYLE on top (public/css/designs/<name>.css): page, canvas, ink, text, muted, border, primary, on_primary, font, radius, card
Parameters
-
$public, defaultnull
Source: framework/core/Notify.php:353
public static function page($title, $text, $status = 200)A short page for the links of the emails (Route::notifications)
Parameters
$title$text-
$status, default200
Source: framework/core/Notify.php:396
public static function offered()The channels the app offers (NOTIFY_CHANNELS, push,email by default)
Source: framework/core/Notify.php:413
public static function prefer($userId, $channel, $enabled)Turns a channel on or off for a user (a channel without a choice is on)
Parameters
$userId$channel$enabled
Source: framework/core/Notify.php:423
public static function enabled($userId, $channel)No doc comment.
Parameters
$userId$channel
Source: framework/core/Notify.php:430
public static function status($userId)What a user sees about their notifications: the channels, their state and the push public key
Parameters
$userId
Source: framework/core/Notify.php:439
public static function base()The app's address, ending with /: APP_URL, else the address of the current web request (null on the command line without APP_URL)
Source: framework/core/Notify.php:478
Caligrafy: Describe it. Approve it. Ship it. Your idea turned into a complete app: every feature built once, for web pages, Vue apps, a REST API and AI agents, and online.
Why Caligrafy: the benefits, the measurements, and what it is not yet
-
Quickstart with Claude: describe it, approve it, ship it
or the Quickstart: the same three steps by hand, in 5 minutes
- How Caligrafy works: the ideas in 5 minutes
- Your first capability: build a feature, page included
-
Capabilities in depth
-
#[Capability]: every option - Scheduled jobs: capabilities on a timer
- Notifications: web push and email
- Background jobs: capabilities run later
- Migrations: database changes, in order
- The cache
-
Testing your app
- Dependency injection
- Validation rules
-
Web pages
- Views and page components
- Design styles: another look, one setting
- Declarative routes: every request, in one line
-
Route::page·Route::form·Route::auth·Route::webhook·Route::download·Route::redirect·Route::action·Route::snap· capability routes - How to export a list as CSV
- Controllers: moving one to a declared route · how to, step by step
- Forms and helpers
-
Vue apps
-
Mobile and tablet
-
REST API
-
AI agents
-
Snap Cards and the assistant
- Payments: Stripe and crypto
- Face detection and face login
- OpenAI: chat and images · Assistants
- Open models: Llama, Mistral...
- Chatbots with Watson
- Machine learning in the browser
- Metadata and social cards · search and analytics
-
Putting it online: the production image, the database at every start
-
API reference: every class and method
-
Routing ·
Route·AuthRoutes· pages ·Controller· capabilities -
Data ·
Model·Query· sign-in · jobs ·Notify· payments · AI -
Interfaces · Snap ·
Snap\Cards·Snap\Conversation· testing · tooling · helper functions
-
Routing ·
-
Caligrafer: every command
- Project · build · data · agents · jobs and tests · maintenance · deploy
- Installation, configuration and Caligrafer
- Routing · Request · Controllers · Views
- Vue: flow of information · routes · validations
- Security and upgrading
- Release notes: 2.26 · 2.25 · 2.24 · 2.23 · 2.22 · 2.21 · 2.20 · 2.19 · 2.18 · 2.17 · 2.16 · 2.15 · 2.14 · 2.13 · 2.12 · 2.11 · 2.10 · 2.9 · 2.8 · 2.7 · 2.6 · 2.5 · 2.4 · 2.3 · 2.1 · October 2026 · changelog
- Testing Caligrafy (contributors)