Bundle around the WebPush library

Overview

MinishlinkWebPushBundle

This bundle provides a simple integration of the WebPush library.

SensioLabsInsight

Usage

Web Push sends notifications to endpoints which server delivers web push notifications as described in the Web Push API specification.

<?php
/** @var \Minishlink\WebPush\WebPush */
$webPush = $this->container->get('minishlink_web_push');

The bundle provides a new minishlink_web_push service that returns an instance of Minishlink\WebPush\WebPush.

For more info on what you can do with $webPush, check Minishlink/web-push.

Installation

  1. composer require minishlink/web-push-bundle
  2. Enable the bundle in your app/AppKernel.php.
<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Minishlink\Bundle\WebPushBundle\MinishlinkWebPushBundle(),
        // ...
    );
}

Configuration

Here is the default configuration, you may change it in your app/config/config.yml.

minishlink_web_push:
  VAPID:
    subject: https://yoursite.com # can be an URL or a mailto:
    publicKey: ~88 chars          # uncompressed public key P-256 encoded in Base64-URL
    privateKey: ~44 chars         # the secret multiplier of the private key encoded in Base64-URL
    pemFile: path/to/pem          # if you have a PEM file and can link to it on your filesystem
    pem: pemFileContent           # if you have a PEM file and want to hardcode its content
  ttl: 2419200                    # Time to Live of notifications in seconds
  urgency: ~                      # can be very-low / low / normal / high
  topic: ~                        # default identifier for your notifications
  timeout: 30                     # Timeout of each request in seconds
  automatic_padding: true         # pad messages automatically for better security (against more bandwith usage)
Comments
  • Not all configs are handled

    Not all configs are handled

    PHP Fatal error: Uncaught exception 'Symfony\Component\Config\Definition\Exception\InvalidConfigurationException' with message 'Unrecognized option "automatic_padding" under "minishlink_web_push"'

    I think automatic_padding is not handled in this bundle.

    opened by andreybrokeit 16
  • not installable under Symfony 3.1

    not installable under Symfony 3.1

    Hi,

    would like to try your bundle, but can't install it under Symfony 3.1. The requirement of mdanter/ecc seems to conflict with the requirements from symfony/polyfill-php70, which is a requirement of symfony:

    composer require minishlink/web-push-bundle:

    Your requirements could not be resolved to an installable set of packages.
    
      Problem 1
        - Installation request for minishlink/web-push-bundle ^1.3 -> satisfiable by minishlink/web-push-bundle[v1.
    3].
        - minishlink/web-push-bundle v1.3 requires minishlink/web-push ^1.3.0 -> satisfiable by minishlink/web-push
    [v1.3, v1.3.1, v1.3.2].
        - minishlink/web-push v1.3 requires mdanter/ecc ^0.4.0 -> satisfiable by mdanter/ecc[v0.4.0].
        - minishlink/web-push v1.3.1 requires mdanter/ecc ^0.4.0 -> satisfiable by mdanter/ecc[v0.4.0].
        - minishlink/web-push v1.3.2 requires mdanter/ecc ^0.4.0 -> satisfiable by mdanter/ecc[v0.4.0].
        - Conclusion: don't install mdanter/ecc v0.4.0
    

    composer require mdanter/ecc:

      Problem 1
        - Installation request for mdanter/ecc ^0.4.0 -> satisfiable by mdanter/ecc[v0.4.0].
        - Conclusion: remove paragonie/random_compat v2.0.3
        - Conclusion: don't install paragonie/random_compat v2.0.3
        - mdanter/ecc v0.4.0 requires paragonie/random_compat 1.4.1|2.0.2 -> satisfiable by paragonie/random_compat[v1.4.1, v2.0.2].
        - Can only install one of: paragonie/random_compat[v1.4.1, v2.0.3].
        - Can only install one of: paragonie/random_compat[v2.0.2, v2.0.3].
        - Installation request for paragonie/random_compat (locked at v2.0.3) -> satisfiable by paragonie/random_compat[v2.0.3].
    

    Is there a way to get around this?

    opened by ThomasTr 8
  • Support Minishlink/web-push version 5

    Support Minishlink/web-push version 5

    This bundle is limited to version 4 of minishlink/web-push, but version 5 is here for some time now. Please support it in a new major version of the.

    And perhaps just skip version 4 in that bundle to synchronize the major version of the bundle with the main library :)

    It appears there is one deprecation which pops up with 4.2

    https://github.com/Minishlink/web-push-bundle/blob/0c3b1fe4156dee7491bc75cdfbbe25c1fd74c0a6/DependencyInjection/Configuration.php#L17

            $treeBuilder = new TreeBuilder();
            $rootNode = $treeBuilder->root('minishlink_web_push');
    // Should become
            $treeBuilder = new TreeBuilder('minishlink_web_push');
            $rootNode = $treeBuilder->getRootNode();
    
    opened by arjenm 4
  • Create a branch for minishlink/web-push:2.0

    Create a branch for minishlink/web-push:2.0

    Hello, thanks for your bundle.

    Could you create a branch to minishlink/web-push:2.0? It seens that i need to run that version to be compatible with PHP 7.2.

    Thanks

    opened by vjnrv 3
  • Outdated dependency

    Outdated dependency

    Thank you for this bundle. I have a question regarding its actuality; when running composer outdated, it lists the dependency minishlink/web-push v2.0.1 as outdated. The current version is ~ v4.0.2. Is there a specific reason for beeing outdated? If not, is someone working or should I open a PR for an upgrade?

    Best regards

    opened by GenieTim 2
  • VAPID config not found in bundle config resulting in endpoint reporting 401 missing auth headers

    VAPID config not found in bundle config resulting in endpoint reporting 401 missing auth headers

    https://github.com/Minishlink/web-push-bundle/blob/e6d2dd8496d2f41e1e86f4e299f50eb5dad788f2/DependencyInjection/MinishlinkWebPushExtension.php#L31

    I'm not sure but the last bundle update to version 6 seems to break the VAPID-config. Currently the auth array seems to miss the VAPID-key. Adding the key fixes the missing config for me:

    $container->setParameter('minishlink_web_push.auth', isset($config['VAPID']) ? ['VAPID' => $config['VAPID']] : []);
    
    opened by veldenb 1
  • Sending with payload not working

    Sending with payload not working

    I am unable to send notifications with payloads. Each time the payload is not empty, the request is sent and sendNotification method returns true (when I dumped response, status code was 201), but no notification is delivered.

    $webPush = $this->get('minishlink_web_push');
    
            $notifications = [
                [
                    'subscription' => Subscription::create([
                        'endpoint' => 'https://fcm.googleapis.com/fcm/send/chvo9gq76WU:APA91bHh661rEeUWR14F9VTyghQTu1qNAQOGFEH0rbwWSsKRjxR9NP2hzyoryMOYLNHBgGnEnCeOuPwXOtTd2uSd8Ks8lWeLyzzXvNWWBj-H1DzN5rQGgsij7lv-2sZWPu6kZJ9dlUZm', // Firefox 43+,
                        'publicKey' => 'publicKey', // base 64 encoded, should be 88 chars
                        'authToken' => 'authToken', // base 64 encoded, should be 24 chars
                    ]),
                    'payload' => 'hello !',
                ]
            ];
    
            foreach ($notifications as $notification) {
                $webPush->sendNotification(
                    $notification['subscription'],
                    $notification['payload']
                );
            }
            $webPush->flush();
    
    opened by Roman9961 1
  • web push api issues in using wamp

    web push api issues in using wamp

    hi i am trying to use https://github.com/web-push-libs/web-push-php

    there are issues in using on local server wamp

    want to use this for send push notification

    use Minishlink\WebPush\WebPush;

    // array of notifications $notifications = array( array( 'endpoint' => 'https://updates.push.services.mozilla.com/push/abc...', // Firefox 43+ 'payload' => 'hello !', 'userPublicKey' => 'BPcMbnWQL5GOYX/5LKZXT6sLmHiMsJSiEvIFvfcDvX7IZ9qqtq68onpTPEYmyxSQNiH7UD/98AUcQ12kBoxz/0s=', // base 64 encoded, should be 88 chars 'userAuthToken' => 'CxVX6QsVToEGEcjfYPqXQw==', // base 64 encoded, should be 24 chars ), array( 'endpoint' => 'https://android.googleapis.com/gcm/send/abcdef...', // Chrome 'payload' => null, 'userPublicKey' => null, 'userAuthToken' => null, ), array( 'endpoint' => 'https://example.com/other/endpoint/of/another/vendor/abcdef...', 'payload' => '{msg:"test"}', 'userPublicKey' => '(stringOf88Chars)', 'userAuthToken' => '(stringOf24Chars)', ), );

    $webPush = new WebPush();

    // send multiple notifications with payload foreach ($notifications as $notification) { $webPush->sendNotification( $notification['endpoint'], $notification['payload'], // optional (defaults null) $notification['userPublicKey'], // optional (defaults null) $notification['userAuthToken'] // optional (defaults null) ); } $webPush->flush();

    // send one notification and flush directly $webPush->sendNotification( $notifications[0]['endpoint'], $notifications[0]['payload'], // optional (defaults null) $notifications[0]['userPublicKey'], // optional (defaults null) $notifications[0]['userAuthToken'], // optional (defaults null) true // optional (defaults false) );

    issues in using use Minishlink\WebPush\WebPush; and plz which url to use in endpoint ?

    opened by opensourcewebapplications 1
  • Fix deprecations for yml

    Fix deprecations for yml

    Symfony throws this deprecation notice: "Not quoting the scalar "%minishlink_web_push.class%" starting with the "%" indicator character is deprecated since Symfony 3.1 and will throw a ParseException in 4.0"

    opened by gab3sz 1
  • Support Symfony 5

    Support Symfony 5

    I would like to use this library with Symfony 5.

    I have not used the bundle with version 4, therefore I don't know if any deprecations came up. I guess it is only required to update the composer.json?

    opened by juliusstoerrle 0
  • upgrade dependencies and add first test

    upgrade dependencies and add first test

    As to resolve #9 , this is my suggestion. It jumps straight up to v4 of the child repo and equally requires PHP >= 7.1 from now on. I allowed myself to add a first unit test, although I quickly realized that it is not really necessary like this yet. Probably, it would be a good idea to test multiple configurations, with the configurations as in the tests of the web-push library, but for now, as I do not fear any breaking changes in the order of the arguments, I suggest to postpone that.

    opened by GenieTim 0
  • Support of PHP versions?

    Support of PHP versions?

    I see this library still supports PHP 7.1, which is End of Life (EOL) for a long time. Even 7.3 is EOL as of today.

    What's the policy about PHP support? The only supported versions are 7.4, 8.0 and 8.1

    In my opinion libraries should drop support of PHP versions that are end of life, because it makes contributing to this library much easier.

    opened by stephanvierkant 1
  • The

    The "minishlink_web_push" service or alias has been removed or inlined when the container was compiled.

    When using Symfony 4, this bundle cannot be called with $this->getContainer()->get('minishlink_web_push');

    The fix is to declare the minishlink_web_push service as public.

    Thanks !

    opened by galphanet 1
Releases(v6.0.3)
Owner
Louis Lagrange
Freelance Software Engineer - Mobile app and API development
Louis Lagrange
It's Pimcore Bundle to send notifications to Google Chat, Slack or Email from admin panel inside Pimcore

Send notifications to Discord, Google Chat, Slack and more from Pimcore It's Pimcore Bundle to send notifications to Discord, Google Chat, Slack, Tele

LemonMind.com 6 Aug 31, 2022
Standalone PHP library for easy devices notifications push.

NotificationPusher Standalone PHP library for easy devices message notifications push. Feel free to contribute! Thanks. Contributors Cédric Dugat (Aut

Cédric Dugat 1.2k Jan 3, 2023
A very lightweight library to handle notifications the smart way.

NAMSHI | Notificator Notificator is a very simple and lightweight library to handle notifications the smart way. It took inspiration from other librar

Namshi 187 Nov 4, 2022
A PHP Library to easily send push notifications with the Pushwoosh REST Web Services.

php-pushwoosh A PHP Library to easily send push notifications with the Pushwoosh REST Web Services. First sample, creating a Pushwoosh message // Crea

gomoob 63 Sep 28, 2022
A Toast notification library for the Laravel TALL stack.

A Toast notification library for the Laravel TALL stack. You can push notifications from the backend or frontend to render customizable toasts with almost zero footprint on the published CSS/JS ????

John F 365 Jan 7, 2023
Push notifications Library for PHP

Push notifications Library for PHP Supported Protocols Protocol Supported Driver Options APNs (Token Based) ✓ APNs\Token APNs\Token\Option APNs (Certi

Norifumi SUNAOKA 3 Dec 14, 2022
Server-side library for working with Expo using PHP

expo-server-sdk-php Server-side library for working with Expo using PHP. If you have any problems with the code in this repository, feel free to open

Cedric Twillie 34 Dec 30, 2022
Standalone PHP library for easy devices notifications push.

NotificationPusher Standalone PHP library for easy devices message notifications push. Feel free to contribute! Thanks. Contributors Cédric Dugat (Aut

Cédric Dugat 1.2k Jan 3, 2023
WebPush can be used to send notifications to endpoints which server delivers Web Push

WebPush can be used to send notifications to endpoints which server delivers Web Push notifications as described in the Web Push protocol. As it is standardized, you don't have to worry about what server type it relies on.

null 1.5k Jan 7, 2023
This plugin integrates cache functionality into Guzzle Bundle, a bundle for building RESTful web service clients.

Guzzle Bundle Cache Plugin This plugin integrates cache functionality into Guzzle Bundle, a bundle for building RESTful web service clients. Requireme

Vlad Gregurco 11 Sep 17, 2022
A PHP library to deal with all those media services around, parsing their URLs and displaying their audios/videos.

MediaEmbed A utility library that generates HTML embed tags for audio or video located on a given URL. It also parses and validates given media URLs.

Mark Sch. 165 Nov 10, 2022
A simple wrapper around vlucas' PHP dotenv library for Kirby CMS.

kirby-phpdotenv A simple wrapper around vlucas' PHP dotenv library for Kirby CMS. Why? I've been using .env in my Kirby projects for a while, but I go

Steve Jamesson 5 Feb 6, 2020
Thin Wrapper around rbenv for PHP version managment

phpenv ![Gitter](https://badges.gitter.im/Join Chat.svg) Sets up a separate rbenv environment for PHP man page SYNOPSIS phpenv-install.sh UPDATE=yes p

Christoph Hochstrasser 571 Dec 29, 2022
A simple but powerful API for processing & compiling assets built around Webpack

Webpack Encore: A Simple & Powerful Webpack API Webpack Encore is a simpler way to integrate Webpack into your application. It wraps Webpack, giving y

Symfony 2.1k Jan 5, 2023
Laravel wrapper around OAuth 1 & OAuth 2 libraries.

Introduction Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub, GitL

The Laravel Framework 5.2k Dec 27, 2022
A developer-friendly wrapper around execution of shell commands.

ptlis/shell-command A developer-friendly wrapper around execution of shell commands. There were several goals that inspired the creation of this packa

brian ridley 18 Dec 31, 2022
A PHP wrapper around the Git command line utility.

Git Wrapper provides a readable API that abstracts challenges of executing Git commands from within a PHP process for you.

Chris Pliakas 503 Nov 21, 2022
WordPlate is a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate is simply a wrapper around WordPress. It makes developers life easier. It is just like building any other WordPress website with themes and plugins. Just with sprinkles on top.

WordPlate 1.7k Dec 24, 2022
ExpressionEngine is a flexible, feature-rich, free open-source content management platform that empowers hundreds of thousands of individuals and organizations around the world to easily manage their web site.

ExpressionEngine CMS ExpressionEngine is a mature, flexible, secure, free open-source content management system. It is beloved by designers for giving

ExpressionEngine 412 Dec 27, 2022
This is a plugin for pocketmine-mp, when locking a player's items helps players not to lose items or throw things around causing server lag.

[] LockedItem| v1.0.0 Player's item lock Features Player's item lock Players aren't afraid of losing items For Devolopers You can access to LockedItem

JeroGamingYT 3 Jan 4, 2022