Download the PHP package tobento/app-notifier without Composer
On this page you can find all versions of the php package tobento/app-notifier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package app-notifier
App Notifier
App Notifier provides powerful and flexible notification support for Tobento applications.
It builds on the underlying Notifier Service and adds:
- application-level integration
- browser notifications (pull, SSE, guest)
- storage notifications
- unified formatting
- feature-based configuration
- view integration and assets
- channel discovery and availability helpers
Whether you need real-time browser updates, guest notifications, or persistent storage-based messages, App Notifier gives you a consistent API and a clean integration layer for your Tobento App.
Table of Contents
- Getting Started
- Requirements
- Documentation
- App
- Notifier Boot
- Notifier Config
- Channels
- Supported Channels
- Available Channels
- Features
- Browser Feature
- Browser Stream Feature
- Browser Guest Feature
- Browser View Feature
- Creating And Sending Notifications
- Using General Recipients
- Using Guest Recipient
- Browser Message
- Queuing Notifications
- Notification Formatters
- General Notification Formatter
- Creating Notification Formatters
- Custom Notifications
- Console
- Clear Notifications Command
- App Notification Integration
- Credits
Getting Started
Add the latest version of the app notifier project running this command.
Requirements
- PHP 8.4 or greater
Documentation
App
Check out the App Skeleton if you are using the skeleton.
You may also check out the App to learn more about the app in general.
Notifier Boot
The Notifier boot integrates the notifier system into your application.
It performs the following tasks:
- loads and applies the notifier configuration
- registers and implements all notifier-related interfaces
- boots the configured features
Below is an example of how to initialize the app with the Notifier boot:
Notifier Config
The configuration for the notifier is located in the app/config/notifier.php file of the default App Skeleton.
This file allows you to configure all notifier-related settings, including:
- which notification channels your application should use
- which features should be enabled (Browser, BrowserStream, BrowserGuest, etc.)
- which notification formatters should be applied
- channel-specific options such as SMS DNS or browser channel names
You can adjust this configuration to match the needs of your application.
Channels
Supported Channels
By default, the following channels are supported:
-
Mail Channel
You only need to configure your mailers in the Mail Config file. -
Sms Channel - Vonage
You only need to configure the DNS settings in the Notifier Config file. -
Storage Channel
Stores notifications for later retrieval (e.g., user inbox, dashboard). - Browser Channel
Provides browser-based notifications.
This includes:- Browser (pull-based) - authenticated users
- BrowserStream (SSE) - authenticated users, real-time
- BrowserGuest - unauthenticated users
These channels are enabled through the corresponding features in the Features section.
Available Channels
Available channels represent the channels that are currently active and usable in your application.
They can be used to:
- restrict which channels a service may use
- display channel names or titles in the UI
- customize channel titles
- sort or map channels
By default, all channels defined in the app/config/notifier.php file are available.
Features
Browser Feature
The Browser Feature enables pull-based browser notifications for authenticated users.
Authentication is handled automatically through the application's user system.
This feature boots the following user-related components:
Tobento\App\User\Boot\Userfrom app-userTobento\App\User\Boot\Aclfrom app-userTobento\App\User\Boot\HttpUserErrorHandlerfrom app-user
Because of this, the Browser Feature works out of the box with the default user system.
If you need web-based authentication, you may install app-user-web.
The authenticated user is resolved from the request via:
The feature then checks:
- the user must implement UserInterface
- the user must be authenticated
- the user must have the required ACL permission (unless ACL is disabled)
If any of these conditions fail, an AuthorizationException is thrown.
Requirements
This feature requires the Browser View Feature which automatically injects its required view snippet into your layout using autoRenderOnView.
Config
You can configure the Browser Feature in the Notifier Config file:
ACL Permissions
To receive browser notifications, a user must have the following permission:
- User can receive browser notifications
If using the App Backend, you can assign this permission on the Roles or Users page.
How Notifications Are Delivered
When the browser polls the route:
The feature:
- Resolves the authenticated user
- Checks ACL (unless disabled)
- Fetches unread notifications from the configured browser channels
- Marks them as read
- Returns them in the JS-Notifier format
This is handled in the browser() method of the feature.
Browser Stream Feature
The Browser Stream Feature enables real-time browser notifications using Server‑Sent Events (SSE).
Unlike the Browser Feature, which relies on polling, this feature pushes notifications to the browser instantly as they occur.
Authentication is handled automatically through the application's user system.
This feature boots the following user-related components:
Tobento\App\User\Boot\Userfrom app-userTobento\App\User\Boot\Aclfrom app-userTobento\App\User\Boot\HttpUserErrorHandlerfrom app-user
Because of this, the Browser Stream Feature works out of the box with the default user system.
If you need web-based authentication, you may install app-user-web.
The authenticated user is resolved from the request via:
The feature then checks:
- the user must implement UserInterface
- the user must be authenticated
- the user must have the required ACL permission (unless ACL is disabled)
If any of these conditions fail, an AuthorizationException is thrown.
Requirements
This feature requires the Browser View Feature which automatically injects its required view snippet into your layout using autoRenderOnView.
Config
You can configure the Browser Stream Feature in the Notifier Config file:
ACL Permissions
To receive browser notifications, a user must have the following permission:
- User can receive browser notifications
If using the App Backend, you can assign this permission on the Roles or Users page.
How Notifications Are Delivered
When the browser connects to the SSE endpoint:
The feature:
- Resolves the authenticated user
- Checks ACL (unless disabled)
- Opens a persistent SSE connection
- Streams new notifications in real time
- Marks streamed notifications as delivered
This is handled in the browser() method of the feature.
Browser Guest Feature
The Browser Guest Feature enables browser notifications for guest users (non-authenticated visitors).
This is useful when your application needs to display notifications to users who are not logged in, such as storefront visitors, checkout flows, or public-facing pages.
Guest notifications are handled separately from authenticated user notifications and do not require a user account.
This feature boots the following user-related components:
Tobento\App\User\Boot\Userfrom app-userTobento\App\User\Boot\Aclfrom app-userTobento\App\User\Boot\HttpUserErrorHandlerfrom app-user
Because of this, the Browser Guest Feature works out of the box with the default user system.
If you need web-based authentication for other features, you may install app-user-web.
Guest notifications do not require an authenticated user.
Instead, the feature identifies the guest using a unique guest token stored in the session or cookie.
This feature does not require the Browser View Feature.
The feature registers its own view handler internally and will only render the snippet if:
- the user (guest) is allowed to receive browser notifications
- the
notifications.browser.guestroute exists - ACL allows access (unless ACL is disabled)
If these conditions are not met, the view is not rendered.
Config
You can configure the Browser Guest Feature in the Notifier Config file:
ACL Permissions
To receive browser notifications, a user must have the following permission:
- User can receive browser notifications
If using the App Backend, you can assign this permission on the Roles or Users page.
How Guest Notifications Are Delivered
When the browser polls the guest endpoint:
The feature:
- Resolves the guest identifier (session-based or cookie-based)
- Checks ACL (unless disabled)
- Fetches unread guest notifications from the configured browser channels
- Marks them as read
- Returns them in the JS-Notifier format
This is handled in the browser() method of the feature.
Sending Notifications
See Using Guest Recipient for how to send notifications to guests.
Browser View Feature
The Browser View Feature provides the view snippet required for enabling browser notifications in your application's layout.
It does not register routes or deliver notifications - it only injects the JavaScript and HTML needed for the browser to poll or stream notifications.
This feature boots the following components:
Tobento\App\View\Boot\Viewfrom app-view
Because of this, the Browser View Feature works out of the box with the default view system.
Config
You can configure the Browser View Feature in the Notifier Config file:
What This Feature Does
The feature registers a handler for the view key:
notifier.browser
This handler:
- checks ACL (
notifications.browser) - checks whether the user is allowed to receive browser notifications
(based on authentication state and preferred notification channels) - resolves the pull and stream URLs:
notifications.browsernotifications.browser.stream
- injects the view file:
notifier/browser
If any condition fails (ACL, user preference, missing route), the snippet is not rendered.
Creating And Sending Notifications
Using General Recipients
For more details, see the Notifier Service - Creating And Sending Notifications.
Example sending to the current user (authenticated or guest)
Make sure you have booted:
If any browser features are enabled, it is automatically booted.
Using Guest Recipient
For more details, see the Notifier Service - Guest Recipient.
For more details, see the Notifier Service - Creating And Sending Notifications.
Browser Message
Use the browser message type to send notifications to the in-browser js-notifier UI.
js-notifier parameters
You can find the full list of supported js-notifier parameters here: https://github.com/tobento-ch/js-notifier#parameters
Formatters
If you use action parameters (action_text, action_route, etc.), ensure the General Notification Formatter is enabled.
This formatter is enabled by default.
Using AbstractNotification
Queuing Notifications
Sending notifications can be a time-consuming task. To avoid delays during request handling, you can queue notification messages for background processing.
To queue a notification, simply add the Queue Parameter to your message:
Example
The App Queue Boot, enabling queue support out of the box.
You only need to configure your queues in the Queue Config file.
Notification Formatters
Notification formatters may be used to format notifications stored by the Storage Channel or the Browser Channel.
General Notification Formatter
You may use the general formatter, which uses the following message data:
In :
The and values will be used to generate the message URL if you have installed the App Http - Routing Boot.
The and values will be translated by the formatter if you have installed the App Translation Boot.
General Formatter Example
You may create your own general formatter for notifications:
In :
Creating Notification Formatters
You may create a specific formatters to format only certain notifications:
In :
Custom Notifications
You may easily customize notifications by defining them in the app/config/notifier.php file:
Creating Custom Notification
Creating Notification Factory
Console
Clear Notifications Command
If you have installed the App Console, you may clear all notifications from channels that support it, such as the Storage Channel and Browser Channel, using the user:notifications:clear command.
Clearing all notifications from all supported channels
Clearing all notifications from all specific channels
Available Options
| Option | Description |
|---|---|
--channel=name |
The name(s) of the channel(s) to clear. |
--read-only |
Clears only notifications that are marked as read. |
--unread-only |
Clears only notifications that are unread. |
--older-than-days=10 |
Clears notifications older than the specified number of days. |
App Notification Integration
You may also want to explore the App Notification package, which provides seamless integration of notifications into your application.
Credits
- Tobias Strub
- All Contributors
All versions of app-notifier with dependencies
tobento/app Version ^2.0
tobento/app-migration Version ^2.0
tobento/app-queue Version ^2.0
tobento/app-http Version ^2.0
tobento/app-encryption Version ^2.0
tobento/app-language Version ^2.0
tobento/app-mail Version ^2.0
tobento/app-database Version ^2.0
tobento/app-translation Version ^2.0
tobento/app-view Version ^2.0
tobento/app-user Version ^2.0
tobento/service-collection Version ^2.0
tobento/service-autowire Version ^2.0
tobento/service-clock Version ^2.0
tobento/service-notifier Version ^2.0
tobento/service-repository-storage Version ^2.0
tobento/js-notifier Version ^1.0
symfony/vonage-notifier Version ^7.3
psr/container Version ^2.0