Download the PHP package bentools/pusher without Composer
On this page you can find all versions of the php package bentools/pusher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bentools/pusher
More information about bentools/pusher
Files in bentools/pusher
Package pusher
Short Description PHP Asynchronous Push Notification management
License MIT
Informations about the package pusher
PHP Webpush API implementation
Allows to send messages via WebPushAPI, on different providers (Google Chrome, Mozilla), asynchronously, on multiple recipients, using multiple API keys.
[!IMPORTANT]
This repository is no longer maintained and may be removed in a near future. You may consider creating a fork if you still require it.
Looks stable, but still experimental.
Pusher is inspired and based on the awesome minishlink/web-push library, but with a different approach:
- Guzzle 6 has been prefered for sending messages, thanks to its asynchronous and parallel requests management
- A Push object is a bag that contains a Message, and Recipients associated to their handlers.
- A Handler is responsible for the correct delivery of a Message to a Recipient - currently implemented: GCM handler, Mozilla handler.
- Multiple Handlers can be used for a single Push, and a Handler may have several instances (i.e. when you use multiple GCM API keys)
- Every Handler must be able to return a Promise for handling a Push, to make things asynchronous and allow bulk processing
- The Pusher service is responsible to send a Push and change its state (pending => done).
- When the Push is done, it can tell which Recipients have not received the message and why (you may then unsubscribe them)
Several types of Message are implemented:
- A Ping message is a message without payload. Usually your service worker should fetch the payload at that moment (as it was in the earlier Webpush API implementations).
- A Notification message contains a json with all the info to display a Webpush notification (title, body, icon, ...)
- A ServerMessage contains a JSON which should be handled by your service worker to be sent to an active window instead of displaying a notification. This may help in changing remotely the DOM of an opened page.
Some example JS files are provided.
Installation
composer require bentools/pusher
Example usage
Consider the following subscription object:
TODO
- Implement VAPID authentication
- Google FCM handler
- Tests
- Recipes
License
MIT