Skip to content
This repository has been archived by the owner on Mar 15, 2023. It is now read-only.

machour/yii2-web-push-notifications

Repository files navigation

Web Push Notifications for Yii 2


An extension for implementing Web Push Notifications on your website in a breeze.

Documentation is at docs/README.md

Latest Stable Version Total Downloads tests

Installation

The preferred way to install this extension is through composer.

php composer.phar require --prefer-dist machour/yii2-web-push-notification

Configuration

DB

This module use the following tables:

Name Role
{{%wpn_app}} Represents a Web Push application
{{%wpn_subscription}} Represents a Web Push subscriber
{{%wpn_campaign}} Represents a Web Push campaign (ie, a push you've scheduled or sent)
{{%wpn_report}} Links a subscriber to a push (received ? errored ? ..)

Use the following migration to create them:

 ./yii migrate --migrationPath=vendor/machour/yii2-web-push-notifications/src/migrations/

Web

Add this module to your \yii\web\Application config file :

return [
   // ...
    'modules' => [
        'wpn' => [
            'class' => 'machour\yii2\wpn\Module',
        ],
        // ...
    ],
];

Console

Add this module to your \yii\console\Application config file :

return [
    // ...
    'bootstrap' => [..., 'wpn'],
    // ...
        'modules' => [
        'wpn' => [
            'class' => 'machour\yii2\wpn\Module',
        ],
        // ...
    ],
]

You can now register a new application using the ./yii wpn/app/create console command. Arguments are as follow:

USAGE

yii wpn/app/create <name> <host> <subject> [...options...]

- name (required): string
  The application name

- host (required): string
  The hostname where the application will be deployed

- subject (required): string
  The contact for the application. Needs to be a URL or a mailto: URL.
  This provides a point of contact in case the push service needs to contact you