Download the PHP package tobento/app-notification without Composer
On this page you can find all versions of the php package tobento/app-notification. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tobento/app-notification
More information about tobento/app-notification
Files in tobento/app-notification
Package app-notification
Short Description The app notification enables custom notifications, newsletter management and delivery, click and event tracking, and detailed reporting.
License MIT
Homepage https://www.tobento.ch
Informations about the package app-notification
App Notification
The app notification provides the following features:
- app - notifier
- newsletter subscribers
- tracking clicks and events
- reports
Zero-Config Bootstrapping
The Notification system works out-of-the-box with sensible defaults.
Simply register the Notification Boot in your application, and the full notification management UI becomes available immediately - no additional configuration required.
All built-in Channels automatically discovered, listed in the UI, and ready to use. You can create notifications, edit content, preview messages, and send or queue them without writing any custom code.
You only need to customize configuration if you want to override defaults such as:
- available channels (mail, sms, storage, chat, push, browser)
- notification types (Users Notification, Newsletter Notification, Reset Password Notification, Browser Guest Notification)
- permissions and access control
- custom channel implementations
- custom notification types or formatters
- registering tasks for sending notifications (e.g. SendUserNotificationTask)
- multi-app support (defining supported apps per notification type or channel)
Table of Contents
- Getting Started
- Requirements
- Documentation
- App
- Notification Boot
- Notification Config
- Features
- Notifications Feature
- Preview Notification
- Send Notification For Review
- Reports
- Custom Notifications Feature
- Create Custom Notification
- Register Custom Notification
- Manage Custom Notification
- Replace Custom Notification
- Users Notification Feature
- Register User Notification
- Manage User Notification
- Sending User Notifications
- Browser Guest Notification Feature
- Register Browser Guest Notification
- Manage Browser Guest Notification
- Sending Browser Guest Notifications
- Newsletter Feature
- Register Newsletter Notification
- Manage Newsletter Notification
- Sending Newsletters
- Newsletter Subscribers Feature
- Manage Newsletter Subscribers
- Subscriber Owner
- Subscribe And Unsubscribe From Newsletter
- Subscribe Newsletter Feature
- Unsubscribe Newsletter Feature
- Sent Notifications Feature
- Tracking Feature
- Links Tracking
- Events Tracking
- Notifications Feature
- Channels
- Mail Channel
- SMS Channel
- Storage Channel
- Chat Channel
- Push Channel
- Browser Channel
- Placeholders
- Placeholder
- Greeting Placeholder
- Console
- Notifications Send Command
- Purge Tracking Tokens Command
- Custom Loggers
- Learn More
- Using Multiple Apps
- Configure Language For Notifications
- Credits
Getting Started
Add the latest version of the app notification 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.
Notification Boot
The notification boot does the following:
- installs and loads notification config
- implements notification interfaces
- boots notification config
You may install the App Backend and boot the notification in the backend app.
Notification Config
The configuration for the notification is located in the file at the default App Skeleton config location where you can configure features and more.
Features
Notifications Feature
The notifications feature provides a page where users can create, edit and delete any notification types registered such as custom notifications or any other custom notification types created.
Config
In the config file you can configure this feature:
ACL Permissions
- User can access notifications
- User can create notifications
- User can edit notifications
- User can delete notifications
- User can send notifications
If using the App Backend, you can assign the permissions in the roles or users page.
Preview Notification
A preview link is available on the index page and edit page of the notifications if supported by the notification type.
To support previewing, you will use the following two methods on any notification type you want to support it.
Example from the :
You may check out the file too.
Send Notification For Review
On the notifications index page, each notification may have a link to send the notification for reviewing if supported by the notification type.
Sending notifications is supported:
- when a Preview Notification which will be used
- when any other notification the default notification will be used.
Reports
On the notifications index page, each notification may have a link to view reports about sent notifications if supported by the notification type. Reports may differ depending on its notification type. For instance, newsletters notifications, will display the total number of notifications sent, the number of recipients who clicked links if tracking enabled and more.
To support reports, the notification type must implement the and have configured cards using the method.
Example from the :
For further details, please refer to the source file.
You may visit the App Card link to find out more about cards.
Available Cards
- , displays the most clicked links
- , displays the most tracked events
- , displays the recipients click count by channels
Adding Custom Cards Using The ReportCards::class
You can add custom cards onto the class which will be displayed together with the cards defined in the method on the notification types. Use the app method to add cards on demand only:
Adding Or Modifying Cards For Specific Notification Types
You can modify or add cards by simply extending the notification type:
Do not forget to register the customized notification type in the notification config file:
Custom Notifications Feature
You may create custom notifications for replacing notifications send by the App - Notifier.
Create Custom Notification
Lets create a custom notification type for the App User Web - Forgot Password Notification by extending the :
Check out the Placeholders to learn more about it.
Register Custom Notification
config file:
Manage Custom Notification
Custom notifications can be managed by simply enabling the Mail Editor - App Block is used to create the mail messages with, which you may configure to fit your requirements.
Replace Custom Notification
Add the feature to replace notifications with your custom notifications in the app(s) you support. Only notifications with the status will be replaced.
Config
In the config file you can configure this feature:
You may consider using the App Backend to manage custom notifications.
In addition, you may check out the Apps bundle if you want to support multiple apps.
Users Notification Feature
Register User Notification
Register the users notification type so as to config file:
Manage User Notification
User notifications can be easily managed by enabling the Notifications Feature.
Sending User Notifications
You can deliver user notifications created from the web interface by using the Notifications Send Command. There are two main approaches:
Warning Use caution with the option when sending notifications immediately. To avoid timeouts, a maximum of 20 is recommended. When queueing notifications, the interval can be set much higher, with a maximum of 20000 recommended.
Option 1: Using App Schedule
Install the App Schedule bundle and configure a command task:
Option 2: Using App Task
Install the App Task bundle and register the task in the task config file. This allows users to schedule the task directly from the web interface:
Alternatively, you can use the Command Task Registry:
Browser Guest Notification Feature
Browser guest notifications are intended for applications that can serve unauthenticated
visitors. They use the Browser Guest Feature from
App Notifier, which
delivers notifications via browser streams and works out of the box without any push
subscription setup.
However, the notification type still only makes sense for apps that expose a public frontend where guests can receive these browser notifications.
Apps that require authentication only (e.g. backend/admin apps) cannot serve guest
browser notifications and therefore should not be listed in supportedApps
for the BrowserGuestNotification type.
Register Browser Guest Notification
Register the browser guest notification type so you can send browser notifications to guest recipients. Add the type to the app's notification config:
Important
Important
Every app that sends browser guest notifications must register the
BrowserGuestNotificationtype in its ownnotification.php.Even if another app (e.g. root) already registers the type, the target app
(e.g. frontend) must also register it.This is required because the notification job resolves the notification type
inside the target app's container, not the app where the notification was created.
Recursive App Lookup
The findAppsRecursive option controls how the notification job resolves apps when sending browser guest notifications.
If set to false (default), only the apps defined in supportedApps are used
directly. This is the recommended setting for most projects.
If set to true, the job will resolve apps recursively using the app finder.
This allows sending browser guest notifications to apps nested deeper in a
multi-domain or multi-tenant structure.
See Apps
Note
Recursive lookup is rarely needed for browser guest notifications because they are typically sent to a single broadcast recipient. Enable this option only if your app structure requires resolving nested apps.
Manage Browser Guest Notification
Browser guest notifications can be created and managed by enabling the Notifications Feature.
The web interface allows selecting the apps that should receive the browser notification.
Sending Browser Guest Notifications
Browser guest notifications created from the web interface can be delivered using the Notifications Send Command.
There are two main approaches:
Warning
Browser guest notifications are always delivered to a single broadcast recipient.
Therefore, the--intervaloption has no practical effect when sending this
notification type - the system will always process exactly one recipient.You may still specify
--interval, but it will not change the behavior for
browser-guestnotifications.
Option 1: Using App Schedule
Install the App Schedule bundle and configure a command task:
Option 2: Using App Task
Install the App Task bundle and register the task in the task config file. This allows users to schedule the task directly from the web interface:
Alternatively, you can use the Command Task Registry:
Newsletter Feature
Register Newsletter Notification
Register the newsletter notification type so as to config file:
Manage Newsletter Notification
Newsletter notifications can be managed by simply enabling the Notifications Feature.
Sending Newsletters
You can deliver newsletters created from the web interface by using the Notifications Send Command. There are two main approaches:
Warning Use caution with the option when sending notifications immediately. To avoid timeouts, a maximum of 20 is recommended. When queueing notifications, the interval can be set much higher, with a maximum of 20000 recommended.
Option 1: Using App Schedule
Install the App Schedule bundle and configure a command task:
Option 2: Using App Task
Install the App Task bundle and register the task in the task config file. This allows users to schedule the task directly from the web interface:
Alternatively, you can use the Command Task Registry:
Newsletter Subscribers Feature
The newsletter subscribers feature provides a page where users can create, edit and delete newsletter subscribers to send newsletters using the Newsletter Feature.
Config
In the config file you can configure this feature:
ACL Permissions
- User can access newsletter subscribers
- User can create newsletter subscribers
- User can edit newsletter subscribers
- User can delete newsletter subscribers
- User can export newsletter subscribers
- User can import newsletter subscribers
If using the App Backend, you can assign the permissions in the roles or users page.
Manage Newsletter Subscribers
Newsletter Subscribers can be managed by simply enabling this feature and using the web interface.
If the user has the required ACL permissions, Import and Export bulk actions are available, powered by the app-import-export package.
Subscriber Owner
You may optionally link a subscriber to an owner (e.g. a customer or user account) so that the manage newsletter subscribers index and edit pages display the owner's name and, optionally, a link to that owner's edit page.
In the config file you can configure this by implementing both interfaces below:
Both interfaces must be configured together - if either is missing, the owner field and link will not be displayed.
The permission defined on the SubscriberOwnerContext::class controls whether the owner field and link are shown to the current user at all.
Subscribe And Unsubscribe From Newsletter
Using The Subscriber Repository
You may check out the App User and Service User for more information.
Using User Web
If using the App - User Web bundle, you can register the event listener which will subscribe and unsubscribe users from the newsletter after registration and profile updates depending whether the users clicked the newsletter checkbox.
In the config/event.php file add the following listener:
Subscribe Newsletter Feature
The subscribe newsletter feature provides a simple subscribe to newsletter functionality.
Config
In the config file you can configure this feature:
ACL Permissions
- User can subscribe to newsletter
How you assign this permission depends on your app architecture:
- Single app / shared user repository: If your frontend app uses the same user and ACL repository as the App Backend, you can assign the permission there via the roles or users page.
- Multiple apps with separate user repositories: If your frontend app (where this feature is typically enabled - see Using Multiple Apps) manages its own users independently from the backend, you will need to assign the permission using that app's own user/ACL management instead, as the App Backend has no visibility into a separate repository.
Topics
You may configure topics the user can select. In the newsletter type web interface you can specify which topics the newsletter covers and should only be sent to those subscribers who have selected the topics.
In the config file you can configure the topics globally:
Spam Protection
The newsletter subscribe form is protected against spam by default using the App Spam bundle. It uses the spam detector as the defined named detector does not exist. In order to use a custom detector, you will just need to define it on the file:
Rate Limiting
The newsletter subscribe form is rate limitied by default using the Rate Limiter bundle.
You may customize it by overwriting the method:
Available Events
| Event | Description |
|---|---|
| The event will dispatch after a user subscribes to the newsletter. | |
| The event will dispatch after a user subscription failed. |
Unsubscribe Newsletter Feature
The unsubscribe newsletter feature provides a simple unsubscribe from newsletter functionality.
Config
In the config file you can configure this feature:
Use the router to generate unsubscribe links. Make sure you sign the url as the registered route in the feature class is signed too.
You may check out the Signed Routing service for more information.
Additionally, a newsletter notification page.
Warning When using multiple apps, ensure that the is consistently configured in each file, otherwise unsubscribe links may not function properly.
Sent Notifications Feature
This feature is in consideration.
Tracking Feature
The tracking feature will events tracking.
Config
In the config file you can configure this feature:
You may disable tracking using the parameter when registering newsletter notification.
Warning If you do not enable the feature at all, make sure you disable the tracking on all notification types, otherwise tracking links will not be found and result in 404 responses.
Links Tracking
When generating notification content, href links are replaced by a tracking token link, using the implemented and configurable in the querying reports data.
Events Tracking
After a link is clicked, the click ID is stored in the session under the key . You can use this ID to track user activity. You may use the implemented configurable in the config file to store events.
Make sure the uses a storage supporting raw statements as they will be used for querying reports data.
Example
For example, you can record how many orders were generated by a newsletter campaign.
Newsletter notifications have already added the most tracked events card, but you may create a custom report card to display reports about generated orders by a newsletter campaign. Use the app method to register the card on demand only using to add the card:
Check out the reports section to find out more about reports.
Channels
Channels are responsible for rendering the fields required to create channel‑specific messages within the notifications web interface. Based on the configured notification, they generate the corresponding message for the notifier to deliver. In addition, channels manage the notification preview feature.
Configure Channels
Channels can be configure in the notification config file:
Be sure to configure the notifier channels as well.
Mail Channel
The mail channel allows you to create email messages using the Block Mail Editor, which can be customized to meet your requirements. Additionally, it supports uploading email attachments.
Make sure to also configure the corresponding notifier mail channel in the file.
SMS Channel
The SMS channel allows you to create SMS messages.
Make sure to also configure the corresponding notifier sms channel in the file.
Storage Channel
The storage channel enables you to create messages that are displayed on the user notifications page, provided the Notifications Feature from the App User Web is installed.
Make sure to also configure the corresponding notifier storage channel in the file.
Additionally, ensure that the is registered in the same configuration file:
Chat Channel
The chat channel allows you to create chat messages.
Make sure to also configure the corresponding notifier chat channel in the file.
Push Channel
The push channel allows you to create push messages.
Make sure to also configure the corresponding notifier push channel in the file.
Browser Channel
The browser channel allows you to create browser messages that are delivered using the
Browser Feature or Browser Guest Feature from the App Notifier.
Messages created through this channel are rendered in the notifications web interface and
delivered to the browser using streams.
No push subscription setup is required - the browser channel works out of the box.
The browser channel can be used by any notification type that includes it, for example:
- Browser Guest Notification (guest recipients)
- Users Notification (authenticated users)
- Custom notification types that specify
channels: $channels->only('browser')or include'browser'
Placeholders
Placeholders allow the user to insert placeholders like into their content, which can be replaced with dynamic values when the content is rendered.
Placeholders can be defined in notification type classes. See create custom notification for instance.
Placeholder
This placeholder will replace the placeholder defined by the parameter with the defined.
Greeting Placeholder
This placeholder will replace the placeholder with the greeting from the address.
Console
Notifications Send Command
Use the following command to send any type of notifications:
Available Options
| Option | Description |
|---|---|
| The number of notifications to send or queue. | |
| Define the queue name if you want to queue the notification, otherwise notifcation will be sent immediately. | |
| Send only specific types. | |
| Sends notfication with the status. | |
| The maximum number of times a job should be attempted. | |
| The priority when queueing, highest are first prioritized. | |
| If set notification will be encrypted when queueing. |
Check out the Sending Newsletters section to see possible options how to automate this process.
Purge Tracking Tokens Command
Use the following command to delete expired tracking tokens.
Available Options
| Option | Description |
|---|---|
| The number of days to retain tracking tokens after expiring. |
You may install the App Task bundle and register the following task in the task config file which enables users to schedule the task from a web interface:
Example using the Command Task Registry:
Custom Loggers
You can configure custom loggers in the Logging Config file for the following classes, which make use of the Logger Trait.
Learn More
Using Multiple Apps
When using multiple Apps, you may use the App Backend for managing notifications and subscribers. Make sure that you configure the database using the same connection as in this example.
Next, configure the config for another app (frontend). You may visit the Apps documentation to find out more about creating apps.
Finally, in the database config file, in both apps, configure the database:
Configure Language For Notifications
When using multiple apps you may configure languages for the following services in the backend app.
Credits
- Tobias Strub
- All Contributors
All versions of app-notification with dependencies
tobento/app Version ^2.0
tobento/app-block Version ^2.0
tobento/app-card Version ^2.0
tobento/app-crud Version ^2.0
tobento/app-http Version ^2.0
tobento/app-migration Version ^2.0
tobento/app-notifier Version ^2.0
tobento/app-language Version ^2.0
tobento/app-logging Version ^2.0
tobento/app-translation Version ^2.0
tobento/app-user Version ^2.0
tobento/app-view Version ^2.0
tobento/app-import-export Version ^2.0
tobento/service-collection Version ^2.0
tobento/service-repository Version ^2.0
tobento/service-repository-storage Version ^2.0
tobento/service-user Version ^2.0