Download the PHP package thekonz/lighthouse-redis-broadcaster without Composer
On this page you can find all versions of the php package thekonz/lighthouse-redis-broadcaster. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download thekonz/lighthouse-redis-broadcaster
More information about thekonz/lighthouse-redis-broadcaster
Files in thekonz/lighthouse-redis-broadcaster
Package lighthouse-redis-broadcaster
Short Description A lighthouse-php redis broadcaster to be used with laravel-echo-server.
License MIT
Informations about the package lighthouse-redis-broadcaster
Lighthouse Redis Broadcaster
Lighthouse already supports pusher, but does not deliver its own redis based solution. This package enables graphql subscriptions using presence channels of the laravel-echo-server.
For a client solution, check out the Apollo Lighthouse Subscription Link.
Installation
I assume that you already have Lighthouse and laravel-echo-server installed. If not, please check out their installation steps before continuing.
Install the package with composer:
Add the service provider after the Lighthouse subscription service provider in the config/app.php
:
Add this to your .env
:
If you do not set the REDIS_PREFIX
to empty, it will default to <app name>_database_
(by default: laravel_database_
) and all redis channels will be prefixed with it.
Setting up automatic removal of subscription channels
Lighthouse by default does not remove vacated channels. In order to prevent redis from running low on memory all the time, you need to configure the laravel-echo-server to publish updates about its presence channels and run a subscriber that removes vacated channels from redis.
Enable presence channel updates in your laravel-echo-server.json
by setting publishPresence
to true
:
Run the subscription command to remove vacated channels:
Usage
If you are using Apollo, you should use the Apollo Lighthouse Subscription Link.
Create a subscription as described in the Lighthouse docs. For the purpose of demonstration, I assume the subscription is postUpdated
like in the docs.
Now query the api:
The response will be:
Now you may use laravel echo to monitor the subscription as a presence channel:
Contributing and issues
Feel free to contribute to this package using the issue system and pull requests on the develop
branch.
Automated unit tests must be added or changed to cover your changes or reproduce bugs.
All versions of lighthouse-redis-broadcaster with dependencies
nuwave/lighthouse Version ^4
illuminate/support Version ^7.7
illuminate/console Version ^7.7
illuminate/cache Version ^7.7
illuminate/redis Version ^7.7
illuminate/broadcasting Version ^7.7
ext-json Version *