Node Docker container with tlaverdure/laravel-echo-server installed. All of the laravel-echo-server environment variables are usable.
- Add this container to your
docker-compose.yml
with the following service definition.
echo-server:
image: ghcr.io/clevyr/laravel-echo-server
restart: unless-stopped
- If you are using clevyr/docker-caddy, configure the
/socket.io
route by adding the following env to the proxy service.
proxy:
image: ghcr.io/clevyr/caddy
environment:
SOCKETIO_ADDRESS: echo-server:6001
- Install the client libraries
npm install laravel-echo socket.io-client
- Add the following snippet to
resources/js/bootstrap.js
.
import Echo from 'laravel-echo';
window.io = require('socket.io-client');
window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname,
});
- Follow the Laravel Broadcasting documentation to set up and subscribe to a channel.
Refer to the DotEnv section of tlaverdure/laravel-echo-server for an environment variable listing.