Download the PHP package computy/yii2-notifications without Composer

On this page you can find all versions of the php package computy/yii2-notifications. 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 yii2-notifications

yii2-notifications

This module provides a way to sending notifications across a variety of delivery channels, including mail, screen, SMS (via Nexmo), etc. Notifications may also be stored in a database so they may be displayed in your web interface.

Notifications are short messages that notify users of something that occurred in your application. For example, if you are writing a billing application, you might send an "Invoice Paid" notification to your users via the email and SMS channels.

This is a fork of webzop/yii2-notifications. Relevant information for migrating from webzop/yii2-notifications to computy/yii2-notifications is listed under migration.

Requirements

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Usage

Notifications is often used as an application module and configured in the application configuration like the following:

To enable Web Push Notifications browsers is needed to verify your identity. A standard called VAPID can authenticate the application for all browsers. You'll need to create and provide a public and private key for your server. These keys must be safely stored and should not change.

If you want to disable the Web Push Notifications simply set the flag 'notifications.web.enable' to false.

In order to generate the uncompressed public and secret key, encoded in Base64, enter the following in your Linux bash:

Or you can use this method provided in the module:

Create A Notification

Each notification is represented by a single class (typically stored in the app/notifications directory).

Send A Notification

Once the notification is created, you can send it as following:

Specifying Delivery Channels

Every notification class has a shouldSend($channel) method that determines on which type of keys and channels the notification will be delivered. In this example, the notification will be delivered in all channels except "screen" or with key "new_account":

It is possible to limit the amount of same key/user notifications sent to a user through the renotification_time property of the notification. A new notification will be sent only if there aren't others with same user/key sent in the period specified in the property. renotification_time has to be a string accepted by DateInterval::__constructor().

Specifying The Send For Specific Channel

Every channel have a send method that receive a notification instance and define a way of that channel will send the notification. But you can override the send method by define toMail ("to" + [Channel ID]) in notification class. This example show how to do that:

Custom Channels

This module have a some pre-built channels, but you may want to write your own channels to deliver notifications. To do that you need define a class that contains a send method:

You also should configure the channel in you application config:

Screen Channel

This channel is used to show small notifications as above image preview. The notifications will stored in database, so before using this channel, you have to run its migrations scripts:

So you can call the Notifications widget in your app layout to show generated notifications:

Web Push Notification Channel

This channel is used to send web push notification to subscriber. Each notification subscription will be stored in the database, so before using this channel, you have to run its migrations scripts:

So you can call the Notifications widget in your app layout to show generated notifications:

You can customize the HTML template for the widget as follow. Setting template to false will hide all widget HTML and the browser will prompts the user to allow notifications. If you customize the HTML template remember to include a button with id 'js-web-push-subscribe-button':

Remember to place the service-worker.js file in the web root in order to serve the service worker when the WebNotifications widget is initialized.

Migration

The following breaking changes from webzop/yii2-notifications to computy/yii2-notifications need to be considered when migrating:


All versions of yii2-notifications with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
yiisoft/yii2 Version ~2.0.13
minishlink/web-push Version ^9.0.0
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 computy/yii2-notifications contains the following files

Loading the files please wait ....