Download the PHP package stijnhau/push-bundle without Composer
On this page you can find all versions of the php package stijnhau/push-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stijnhau/push-bundle
More information about stijnhau/push-bundle
Files in stijnhau/push-bundle
Package push-bundle
Short Description Web Push (browser notifications) for Symfony apps: subscriptions per user and browser, VAPID sending with expired-subscription cleanup, optional async delivery over Messenger, a subscribe endpoint, a service worker and a small client module.
License MIT
Homepage https://github.com/stijnhau/push-bundle
Informations about the package push-bundle
stijnhau/push-bundle
Web Push (browser notifications) for Symfony apps, shared by CityWars, Crime-Life and F1Manager. It stores which browsers each user subscribed, sends with VAPID through minishlink/web-push, forgets browsers the push service says are gone, and can send from a Messenger worker. What triggers a notification, and whether a user wants it, stays in the app.
| Piece | What it does |
|---|---|
Model\AbstractPushSubscription |
Doctrine mapped superclass: user, endpoint (unique), p256dh key, auth token, created at. renew() when a browser subscribes again. |
Service\PushSubscriptions |
subscribe() (validates the endpoint: https, a known push service), unsubscribe(), forget(), forUser(), subscribedUserIds(). |
Service\PushSender |
send() to every browser of a user now, queue() through Messenger (or now, without it). Best-effort: never throws because of a push service. |
PushMessage |
title, body, url, tag: the JSON payload, already translated. |
Transport\WebPushTransport |
Off while a VAPID setting is empty. Refuses private/loopback addresses (NoPrivateNetworkHttpClient). |
Test\InMemoryPushTransport |
For app tests: records instead of sending. InMemoryPushTransport::install(static::getContainer()). |
| Endpoint | POST the browser's PushSubscription.toJSON(), DELETE {"endpoint"}; logged-in user, CSRF token in a header. |
/sw.js |
The service worker: shows the notification, a click focuses or opens the page (same site only). |
@stijnhau/push-bundle/push.js |
Client module (AssetMapper): sync(), enable(), disable(), current(), configFrom(). No UI. |
stijnhau:push:generate-vapid-keys |
Prints a fresh key pair. |
| Twig | push_public_key() ('' when off), push_enabled(). |
Install
Then run bin/console make:migration. With messenger_transport set the bundle
routes Stijnhau\PushBundle\Messenger\SendPush to that transport.
Routes:
Sending
Browser
Add it to importmap.php as '@stijnhau/push-bundle/push.js' => ['path' => '@stijnhau/push-bundle/push.js'].
An app with its own API can pass save: (method, body) => ... instead of url.
License
MIT, see LICENSE.
All versions of push-bundle with dependencies
doctrine/doctrine-bundle Version ^3.4
doctrine/orm Version ^3.8
guzzlehttp/psr7 Version ^2.7 || ^3.0
minishlink/web-push Version ^11.0
psr/clock Version ^1.0
psr/log Version ^3.0
symfony/clock Version ^8.1
symfony/config Version ^8.1
symfony/dependency-injection Version ^8.1
symfony/framework-bundle Version ^8.1
symfony/http-client Version ^8.1
symfony/http-kernel Version ^8.1