-
-
Save xvladqt/69f5abafcb9c843ed45821dac64dd4ba to your computer and use it in GitHub Desktop.
LaravelEcho + docker + Vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BROADCAST_DRIVER=redis | |
CACHE_DRIVER=redis | |
QUEUE_CONNECTION=redis | |
SESSION_DRIVER=redis | |
REDIS_HOST=redis | |
REDIS_PASSWORD=null | |
REDIS_PORT=6379 | |
MIX_ECHO_HOST=https://demo.local:6001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import LaravelEcho from './plugins/LaravelEcho' | |
Vue.use(VeeValidate); | |
if(process.env.MIX_ECHO_HOST){ | |
Vue.use(new LaravelEcho({ | |
broadcaster: 'socket.io', | |
host: process.env.MIX_ECHO_HOST | |
})); | |
} | |
const app = new Vue({ | |
data(){ | |
return { | |
system: window.system | |
} | |
}, | |
created: function (){ | |
console.log(this.system.user_id); | |
if(this.$laravelEcho && this.system.user_id){ | |
this.$laravelEcho.private(`test.${this.system.user_id}`) | |
.listen('.event', this.operationNotification) | |
.listen('.event', this.operationNotification); | |
} | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
front: | |
image: abiosoft/caddy | |
environment: | |
- CADDYPATH=/etc/caddycerts | |
- ACME_AGREE=true | |
ports: | |
- '80:80' | |
- '443:443' | |
volumes: | |
- './docker/caddy/Caddyfile:/etc/Caddyfile' | |
- './docker/caddy/caddyssl:/etc/caddycerts' | |
- '.:/app' | |
networks: | |
default: | |
aliases: | |
- demo.local | |
echo-server: | |
image: oanhnn/laravel-echo-server | |
volumes: | |
- '.:/app' | |
- './docker/caddy/caddyssl:/etc/certs' | |
ports: | |
- '6001:6001' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"authHost": "https://demo.local", | |
"authEndpoint": "/broadcasting/auth", | |
"clients": [], | |
"database": "redis", | |
"databaseConfig": { | |
"redis": { | |
"host": "redis", | |
"port": "6379", | |
"options": { | |
"db": "0" | |
} | |
}, | |
"sqlite": { | |
"databasePath": "/app/database/laravel-echo-server.sqlite" | |
}, | |
"publishPresence": true | |
}, | |
"devMode": true, | |
"host": null, | |
"port": 6001, | |
"protocol": "https", | |
"sslCertPath": "/etc/certs/demo.local.pem", | |
"sslKeyPath": "/etc/certs/demo.local-key.pem", | |
"subscribers": { | |
"http": true, | |
"redis": true | |
}, | |
"apiOriginAllow": { | |
"allowCors": true, | |
"allowOrigin": "https://demo.local", | |
"allowMethods": "GET, OPTION, POST", | |
"allowHeaders": "Accept, Authorization, Content-Type, Origin, X-Auth-Token, X-CSRF-TOKEN, X-Requested-With, X-Socket-Id" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Echo from 'laravel-echo'; | |
if(!window.io){ | |
window.io = require('socket.io-client'); | |
} | |
export default class LaravelEcho { | |
constructor(options){ | |
this.echo = new Echo(options); | |
} | |
install (Vue) { | |
Vue.prototype.$laravelEcho = this.echo; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment