PHP Web Push Notifications Server: Queue and push notifications to Web users

Recommend this page to a friend!
  Info   View files Example   View files View files (53)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2020-08-12 (1 month ago) RSS 2.0 feedNot enough user ratingsTotal: 473 This week: 7All time: 5,911 This week: 34Up
Version License PHP version Categories
pnserver 1.1.0Freely Distributable7.4Web services, PHP 7
Description Author

This package can queue and push notifications to Web users.

It can register the interest of users to receive notifications from the server by creating user subscriptions.

The package provides means to queue notification messages to be sent to users of an application by storing them in a database.

Then it can return queued messages, so they can be shown to Web uses on a Web page using custom JavaScript code that pulls the messages from the server using this package.

The package can also automatically delete expired messages and no longer valid subscriptions.

Innovation Award
PHP Programming Innovation award winner
April 2020
Winner
Web based push notifications are useful to let users of a site know about anything new that happens on a site that may be of the interest of those users.

This package provides a complete solution to register users interested to subscribe to get notifications from a site, queue notifications to be pushed to the users when they come to the site, and even perform maintenance on the notifications and subscriptions created by the users.

Manuel Lemos
Picture of Stefan Kientzler
  Performance   Level  
Name: Stefan Kientzler is available for providing paid consulting. Contact Stefan Kientzler .
Classes: 11 packages by
Country: Germany Germany
Age: 53
All time rank: 2041129 in Germany Germany
Week rank: 19 Up2 in Germany Germany Up
Innovation award
Innovation award
Nominee: 6x

Winner: 4x

Details

PNServer - Web Push Notifications for your Homepage

Latest Stable Version License Minimum PHP Version PHPStan Scrutinizer Code Quality

With this package, web push notifications can be created, encrypted and sent via HTTP request. The subscriptions can be saved and managed. Optionally, the package automatically deletes expired or no longer valid subscriptions. The JavaScript code required on the client side is also included in the package - this has to be slightly adapted to your own project.

there are no dependencies to other external libraries!

required PHP Libraries

  • cURL (curl)
  • Multibyte String (mbstring)
  • OpenSSL (openssl)
  • GNU Multiple Precision (gmp)
  • BC Math (bcmath)

Installation

You can download the Latest release version from PHPClasses.org

required adaptions for your own project (in PNServiceworker.js):

  // VAPID appPublic key
  const strAppPublicKey   = 'create your own VAPID key pair and insert public key here';
  // URL to save subscription on server via Fetch API
  const strSubscriberURL  = 'https://www.your-domain.org/PNSubscriber.php';
  // default Notification Title if not pushed by server
  const strDefTitle       = 'Your company or product';
  // default Notification Icon if not pushed by server
  const strDefIcon        = './elephpant.png';

you can generate your own VAPID key on https://tools.reactpwa.com/vapid.

Usage

A tutorial describing the individual steps for using the package is available at PHPclasses.org.

PnTestClient.html shows a simple example Page to subscribe the push notifications.

PNTestServer.php demonstrates, how the Notification Server can be implemented:

rename MyVapid.php.org to MyVapid.php and set your own keys:

  $oVapid = new PNVapid(
      "mailto:yourmail@yourdomain.de",
      "your-generated-public-key",
      "your-generated-private-key"
  );

Logging

This package can use any PSR-3 compliant logger. The logger is initialized with a NullLogger-object by default. The logger of your choice have to be passed to the constructor of the PNDataProvider and set via setLogger() method to the PNServer.

If you are not working with a PSR-3 compatible logger so far, this is a good opportunity to deal with this recommendation and may work with it in the future.

There are several more or less extensive PSR-3 packages available on the Internet.

You can also take a look at the 'XLogger' package and the associated blog 'PSR-3 logging in a PHP application' as an introduction to this topic.

  Files folder image Files  
File Role Description
Files folder imagePsr (1 directory)
Files folder imageSKien (2 directories)
Accessible without login Plain text file autoloader.php Aux. Auxiliary script
Accessible without login Image file elephpant.png Icon Icon image
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file MyLogger.php Example Example script
Accessible without login Plain text file MyVapid.php.org Example Example script
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file phpunit.xml.org Data Auxiliary data
Accessible without login Plain text file PNClient.js Data Auxiliary data
Accessible without login Plain text file PNSendWelcome.php Example Example script
Accessible without login Plain text file PNServiceWorker.js Data Auxiliary data
Accessible without login Plain text file PNSubscriber.php Example Example script
Accessible without login Plain text file PNTestClient.html Data Example HTML page client
Accessible without login Plain text file PNTestServer.php Example Example script
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files  /  Psr  
File Role Description
Files folder imageLog (8 files)

  Files folder image Files  /  Psr  /  Log  
File Role Description
  Plain text file AbstractLogger.php Class Class source
  Plain text file InvalidArgumentException.php Class Class source
  Plain text file LoggerAwareInterface.php Class Class source
  Plain text file LoggerAwareTrait.php Class Class source
  Plain text file LoggerInterface.php Class Class source
  Plain text file LoggerTrait.php Class Class source
  Plain text file LogLevel.php Class Class source
  Plain text file NullLogger.php Class Class source

  Files folder image Files  /  SKien  
File Role Description
Files folder imagePNServer (9 files, 1 directory)
Files folder imageTest (1 directory)

  Files folder image Files  /  SKien  /  PNServer  
File Role Description
Files folder imageUtils (4 files)
  Plain text file PNDataProvider.php Class Class source
  Plain text file PNDataProviderMySQL.php Class Class source
  Plain text file PNDataProviderSQLite.php Class Class source
  Plain text file PNEncryption.php Class Class source
  Plain text file PNPayload.php Class Class source
  Plain text file PNServer.php Class Class source
  Plain text file PNServerHelper.php Class Class source
  Plain text file PNSubscription.php Class Class source
  Plain text file PNVapid.php Class Class source

  Files folder image Files  /  SKien  /  PNServer  /  Utils  
File Role Description
  Plain text file Curve.php Class Class source
  Plain text file Math.php Class Class source
  Plain text file NistCurve.php Class Class source
  Plain text file Point.php Class Class source

  Files folder image Files  /  SKien  /  Test  
File Role Description
Files folder imagePNServer (12 files, 1 directory)

  Files folder image Files  /  SKien  /  Test  /  PNServer  
File Role Description
Files folder imagetestdata (6 files)
  Plain text file PNDataProviderMySQLTest.php Class Class source
  Plain text file PNDataProviderSQLiteTest.php Class Class source
  Plain text file PNDataProviderTest.php Class Class source
  Plain text file PNEncryptionTest.php Class Class source
  Plain text file PNPayloadTest.php Class Class source
  Plain text file PNServerTest.php Class Class source
  Plain text file PNSubscriptionTest.php Class Class source
  Plain text file PNVapidTest.php Class Class source
  Plain text file TestHelperTrait.php Class Class source
  Plain text file UtilsCurveTest.php Class Class source
  Plain text file UtilsMathTest.php Class Class source
  Plain text file UtilsPointTest.php Class Class source

  Files folder image Files  /  SKien  /  Test  /  PNServer  /  testdata  
File Role Description
  Accessible without login Plain text file expired_subscription.json Data Auxiliary data
  Accessible without login Plain text file gone_subscription.json Data Auxiliary data
  Accessible without login Plain text file invalid_subscription.json Data Auxiliary data
  Accessible without login Plain text file inv_endpoint_subscription.json Data Auxiliary data
  Accessible without login Plain text file notfound_subscription.json Data Auxiliary data
  Accessible without login Plain text file valid_subscription.json Data Auxiliary data

 Version Control Unique User Downloads Download Rankings  
 100%
Total:473
This week:7
All time:5,911
This week:34Up

For more information send a message to info at phpclasses dot org.