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.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package service-notifier

Notifier Service

Notifier interface for PHP applications using Symfony Notifier as default implementation.

Table of Contents

Getting started

Add the latest version of the notifier service project running this command.

Requirements

Highlights

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.

Composite Notifier

A notifier that forwards the notification to multiple notifiers at once.

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.

Address Recipient

The may be used if you have installed the User Service.

User Recipient

The may be used if you have installed the User Service.

Guest Recipient

The represents a recipient that does not necessarily have a persistent user identity.

It is useful for scenarios such as:

Guest recipients behave like any other recipient but offer additional flexibility for browser-based or temporary notification delivery.

The id may be:

The Notifier does not enforce a specific meaning for the ID.
You are free to choose how guests are identified in your application.

Composite Recipient

The may be used to compose the recipient from multiple recipients. The first found address will be used.

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

Chat Channel Per Recipient

When delivering notifications through the chat channel, you can assign a dedicated chat address to each recipient:

Channel Configuration

You can configure the to ensure that a message is only sent if the recipient has a chat address defined. If no address exists, you may specify an alternative chat channel to handle delivery:

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 StorageRepository::class as the repository implementation for storing notifications.

To use it, install the storage repository service:

Check out the Storage Service - Storages for the available storages.

For more details about repository usage, see the Repository Storage Service.

Storage Notification

To send Storage notifications you have multiple options:

Using the Abstract Notification

Extend the AbstractNotification::class and implement the ToStorage interface.
The interface requires a toStorageHandler method, which is already provided by AbstractNotification.

You only need to implement the toStorage method, which receives:

This method must return a Message\StorageInterface instance.

Using the Notification

Storage Recipient

When sending notifications via the Storage Channel, the channel stores the recipient information using the values returned by $recipient->getId() and $recipient->getType().
These values allow you to later fetch or filter notifications for any recipient type your application defines, such as users, system entities, or custom recipient groups.

Accessing Storage Notifications

Once notifications are stored, you can retrieve the notifications using the repository from the channel:

Browser Channel

The Browser Channel stores notification messages in the configured repository so they can later be delivered to the browser (for example via SSE).

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 Stores the exact date and time when the notification becomes invalid and should no longer be shown to the recipient.
datetime Used to store date read at
datetime Used to store date created at

Browser Repository

You may use the provided StorageRepository::class as the repository implementation for storing browser notifications.

To use it, install the storage repository service:

Check out the Storage Service - Storages for the available storages.

For more details about repository usage, see the Repository Storage Service.

Browser Notification

To send Browser notifications you have multiple options.

Using the Abstract Notification

Extend the AbstractNotification::class and implement the ToBrowser interface.
The interface requires a toBrowserHandler method, which is already provided by AbstractNotification.

You only need to implement the toBrowser method, which receives:

This method must return a Message\BrowserInterface instance.

Using the Notification

Browser Recipient

When sending notifications via the Browser Channel, the channel stores the recipient information using the values returned by $recipient->getId() and $recipient->getType().
These values allow you to later fetch or filter notifications for a specific user, guest, browser ID, or any other recipient type your application defines.

GuestRecipient

A GuestRecipient may be used when sending notifications to anonymous or temporary browser recipients.
If the recipient is a GuestRecipient and defines an expiresAfter value (either an integer in seconds or a DateInterval), the Browser Channel will automatically calculate and store the expires_at timestamp using the injected ClockInterface.

When the id is null, the notification is not tied to a specific user. How this is interpreted is up to your application. For example, you may use it for broadcast-style notifications or identify the browser using a cookie or session value.

For more detail see the Guest Recipient section.

Accessing Browser Notifications

Once notifications are stored, you can retrieve them using the repository provided by 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


All versions of service-notifier with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
tobento/service-filesystem Version ^2.0
tobento/service-autowire Version ^2.0
tobento/service-repository Version ^2.0
tobento/service-mail Version ^2.0
psr/clock Version ^1.0
psr/container Version ^2.0
psr/http-message Version ^2.0
psr/event-dispatcher Version ^1.0
symfony/notifier Version ^7.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tobento/service-notifier contains the following files

Loading the files please wait ...