2017 © Pedro Peláez
 

library push

Web Push library for PHP

image

cmnty/push

Web Push library for PHP

  • Saturday, December 17, 2016
  • by peternijssen
  • Repository
  • 6 Watchers
  • 12 Stars
  • 8,328 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

cmnty/push

Latest Version on Packagist ![Software License][ico-license] Total Downloads, (*1)

Web Push library for PHP, (*2)

Instalation

Require the library with composer:, (*3)

composer require cmnty/push

This library supports both ext-crypto and lib-openssl for it's encryption needs. While a php fallback can be provided by spomky-labs/php-aes-gcm it is advised to use that only as a last resort., (*4)

Usage

<?php

use Cmnty\Push\AggregatePushService;
use Cmnty\Push\Client;
use Cmnty\Push\Crypto\AuthenticationSecret;
use Cmnty\Push\Crypto\PublicKey;
use Cmnty\Push\EndPoint;
use Cmnty\Push\GooglePushService;
use Cmnty\Push\MozillaPushService;
use Cmnty\Push\Notification;
use Cmnty\Push\PushServiceRegistry;
use Cmnty\Push\Subscription;

$notification = new Notification('Hello', 'World!');
$subscription = new Subscription(
    new Endpoint('...'),
    new PublicKey::createFromBase64UrlEncodedString('...'),
    new AuthenticationSecret::createFromBase64UrlEncodedString('...')
);

$pushServiceRegistry = new PushServiceRegistry();
$pushServiceRegistry->addPushService(new GooglePushService('API Key'));
$pushServiceRegistry->addPushService(new MozillaPushService());
$pushService = new AggregatePushService($pushServiceRegistry);
$client = new Client($pushService);

$client->pushNotification($notification, $subscription);

By default, the Cmnty\Push\Crypto\AggregateCrypt class is used to encrypt the notification. This class tries to encrypt the notification using third party libraries or extensions in the following order: * Encrypt using ext-crypto implemented by Cmnty\Push\Crypto\ExtCryptoCrypt * Encrypt using lib-openssl implemented by Cmnty\Push\Crypto\OpenSSLCrypt * Encrypt using native php implemented by Cmnty\Push\Crypto\SpomkyLabsCrypt using spomky-labs/php-aes-gcm, (*5)

You can also force a certain library or extension to be used by passing it to the PushClient:, (*6)

<?php

use Cmnty\Push\Client;
use Cmnty\Push\Crypto\Cryptograph;
use Cmnty\Push\Crypto\ExtCryptoCrypt;

$pushService = ...;
$cryptograph = new Cryptograph(new ExtCryptoCrypt());
$client = new Client($pushService, null, $cryptograph);

If required, you can also provide your own implementation by implementing the Cmnty\Push\Crypto\Crypt interface., (*7)

Framework Integration

Credits

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

17/12 2016

dev-master

9999999-dev

Web Push library for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

push notifications push notifications push messages push api web push web push api

07/09 2016

0.0.1

0.0.1.0

Web Push library for PHP

  Sources   Download

MIT

The Requires

 

push notifications push notifications push messages push api web push web push api