Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fadilxcoder/php-mercure
PHP Mercure Protocol - real-time communications
https://github.com/fadilxcoder/php-mercure
client mercure notes php poc server
Last synced: about 1 month ago
JSON representation
PHP Mercure Protocol - real-time communications
- Host: GitHub
- URL: https://github.com/fadilxcoder/php-mercure
- Owner: fadilxcoder
- Created: 2022-11-08T20:38:43.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-08T20:41:11.000Z (over 2 years ago)
- Last Synced: 2024-11-09T14:31:57.474Z (3 months ago)
- Topics: client, mercure, notes, php, poc, server
- Language: PHP
- Homepage:
- Size: 105 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Notes
- https://github.com/dunglas/mercure/releases (Mercure github releases)
```
mercure_0.14.1_Windows_x86_64.zip 14.5 MB Sep 13
```
- Download and extract in `server`
- Launch **Mercure server** : `$ MERCURE_PUBLISHER_JWT_KEY='!ChangeThisMercureHubJWTSecretKey!' MERCURE_SUBSCRIBER_JWT_KEY='!ChangeThisMercureHubJWTSecretKey!' ./server/mercure.exe run -config ./server/Caddyfile.dev`
- https://github.com/dunglas/mercure - Mercure Git repo docs
- https://github.com/symfony/mercure - Mercure Component
- https://symfony.com/blog/symfony-gets-real-time-push-capabilities - (Symfony Gets Real-time Push Capabilities!)
- Mercure server : `https://localhost/.well-known/mercure`
- PHP Server notification dispatcher : `http://localhost/php-mercure/index.php`
- Static Client : `http://localhost/php-mercure/client.php`**Subscribing to updates from a web browser**
- https://mercure.rocks/docs/getting-started (Mercure documentation)
- Static HTML client to recieve notification - `client.php````js
// The subscriber subscribes to updates for the https://example.com/users/dunglas topic
// and to any topic matching https://example.com/books/{id}
const url = new URL('https://localhost/.well-known/mercure');
url.searchParams.append('topic', 'https://localhost/demo/books/1.jsonld');
url.searchParams.append('topic', 'https://example.com/users/dunglas');
// The URL class is a convenient way to generate URLs such as https://localhost/.well-known/mercure?topic=https://example.com/books/{id}&topic=https://example.com/users/dunglasconst eventSource = new EventSource(url);
// The callback will be called every time an update is published
eventSource.onmessage = e => console.log(e); // do something with the payload
```---