Download the PHP package tobento/service-notifier without Composer
On this page you can find all versions of the php package tobento/service-notifier. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package service-notifier
Notifier Service
Notifier interface for PHP applications using Symfony Notifier as default implementation.
Table of Contents
- Getting started
- Requirements
- Highlights
- Documentation
- Basic Usage
- Creating And Sending Notifications
- Notifier
- Create Notifier
- Notifications
- Notification
- Abstract Notification
- Recipients
- Recipient
- User Recipient
- Channel
- Mail Channel
- Mail Notification
- Mail Recipient
- Mail Channel Factory
- Sms Channel
- Sms Notification
- Sms Recipient
- Chat Channel
- Chat Notification
- Chat Recipient
- Push Channel
- Push Notification
- Push Recipient
- Storage Channel
- Storage Notification
- Storage Recipient
- Accessing Storage Notifications
- Mail Channel
- Channels
- Default Channels
- Lazy Channels
- Queue
- Events
- Basic Usage
- Credits
Getting started
Add the latest version of the notifier service project running this command.
Requirements
- PHP 8.0 or greater
Highlights
- Framework-agnostic, will work with any project
- Decoupled design
Documentation
Basic Usage
Creating And Sending Notifications
Once you have created the notifier you can create and send notifications:
Check out the Notifications section to learn more about the available notifications you can create or you might create your own notification class fitting your application.
Check out the Recipients section to learn more about the available recipients you can create or you might create your own recipient class fitting your application.
Notifier
Create Notifier
Check out the Channels section to learn more about the available channels.
Notifications
Notification
The may be used to create simple notification messages supporting all channels.
If you want to support custom channels you may consider creating a custom notification!
Available methods
In addition, you may add messages for specific channels:
Abstract Notification
Use the if you want to create specific messages for each channel.
Simply extend from the and add the message interfaces with its method you want to support.
Furthermore, any methods such as will receive a entity, the name and you may request any service being resolved (autowired) by the container.
Recipients
Recipient
The may be used to create a recipient supporting all channels.
User Recipient
The may be used if you have installed the User Service.
Channel
Mail Channel
The mail channel uses the Mail Service to send notifications.
Mail Notification
To send mail notifications you have multiple options:
Using the Abstract Notification
Simply extend from the and implement the interface. The interface requires a method which is already added on the defining the method as the message handler. You will just need to add the method which will receive a entity, the name and you may request any service being resolved (autowired) by the container.
If you do not have defined a default from address, you will need to set it on each message:
Using the Notification
Check out the Mail Message section to learn more about mail messages.
Mail Recipient
When sending notifications via the mail channel, the channel will call the method on the recipient entity to get the email address when no were defined on the mail message.
Mail Channel Factory
Sms Channel
Use the to create a SMS channel using the Symfony SMS Channel:
You will need to install any chat service you would like e.g.
Sms Notification
To send SMS notifications you have multiple options:
Using the Abstract Notification
Simply extend from the and implement the interface. The interface requires a method which is already added on the defining the method as the message handler. You will just need to add the method which will receive a entity, the name and you may request any service being resolved (autowired) by the container.
Using the Notification
Sms Recipient
When sending notifications via the sms channel, the channel will call the method on the recipient entity to get the sms address when no specific were defined.
Chat Channel
Use the to create a chat channel using the Symfony Chat Channel:
You will need to install any chat service you would like e.g.
Chat Notification
To send chat notifications you have multiple options:
Using the Abstract Notification
Simply extend from the and implement the interface. The interface requires a method which is already added on the defining the method as the message handler. You will just need to add the method which will receive a entity, the name and you may request any service being resolved (autowired) by the container.
Using the Notification
Chat Recipient
When sending notifications via the chat channel, you may add a specific channel address with parameters for later usage.
Sample notification with address usage
Push Channel
Use the to create a push channel using the Symfony Push Channel:
You will need to install any push service you would like e.g.
Push Notification
To send push notifications you have multiple options:
Using the Abstract Notification
Simply extend from the and implement the interface. The interface requires a method which is already added on the defining the method as the message handler. You will just need to add the method which will receive a entity, the name and you may request any service being resolved (autowired) by the container.
Using the Notification
Push Recipient
When sending notifications via the push channel, you may add a specific channel address with parameters for later usage.
Sample notification with address usage
Storage Channel
The storage channel stores the notification information in the configured storage repository.
Check out the Repository Service to learn more about it.
The storage needs to have the following table columns:
Column | Type | Description |
---|---|---|
bigint(21) primary key | - | |
varchar(255) | Used to store the notification name | |
varchar(36) | Used to store the recipient id | |
varchar(255) | Used to store the recipient type | |
json | Used to store the message data | |
datetime | Used to store date read at | |
datetime | Used to store date created at |
Storage Repository
You may use the provided as repository implementation:
You will need to install the service:
Check out the Storage Service - Storages for the available storages.
Check out the Repository Storage Service to learn more about it in general.
Storage Notification
To send Storage notifications you have multiple options:
Using the Abstract Notification
Simply extend from the and implement the interface. The interface requires a method which is already added on the defining the method as the message handler. You will just need to add the method which will receive a entity, the name and you may request any service being resolved (autowired) by the container.
Using the Notification
Storage Recipient
When sending notifications via the storage channel, the channel will store the and values which you can later use to fetch notifications:
Accessing Storage Notifications
Once notifications are stored, you can retrieve the notifications using the repository from the channel:
Channels
Default Channels
Lazy Channels
The creates the channels only on demand.
Queue
You may queue your notification by just adding the parameter:
Requirements
To support queuing notifications you will need to pass a queue handler to the notifier.
Consider using the default queue handler using the Queue Service:
First, install the queue service:
Finally, pass the queue handler to the notifier:
Events
You may listen to the following events if your notifier is configured to support it.
Event | Description |
---|---|
The Event will be fired before sending the notification. | |
The Event is fired after the notification is sent. | |
The Event will be fired after queuing the notification. |
When using the default notifier just pass an event dispatcher.
Credits
- Tobias Strub
- All Contributors
- Symfony
All versions of service-notifier with dependencies
tobento/service-filesystem Version ^1.0.5
tobento/service-autowire Version ^1.0
tobento/service-repository Version ^1.0.1
tobento/service-mail Version ^1.0
psr/container Version ^2.0
psr/http-message Version ^1.0
psr/event-dispatcher Version ^1.0
symfony/notifier Version ^6.0