Skip to content

Global Helpers

publish()

publish() — returns struct

Available in: controller, model, mapper, migrator, migration, tabledefinition Category: Channel Functions

Publish an event to a channel. Delegates to the in-memory Channel engine or the DatabaseAdapter depending on the adapter argument (or the global channelAdapter setting). Can be called from controllers, models, jobs, or anywhere with access to global helpers.

NameTypeRequiredDefaultDescription
channelstringyesThe channel name to publish to (e.g. “user.42”).
eventstringyesThe event type (e.g. “notification”, “update”).
datastringyesThe event data as a string (typically JSON).
adapterstringnoAdapter to use: “memory” (default) or “database”.