简体   繁体   English

在 laravel 5.6 中使用 Pusher 有问题

[英]have isuue with using Pusher with laravel 5.6

I'm trying to use pusher with laravel 5.6 and vue.js but i'm always getting error message我正在尝试将 pusher 与 laravel 5.6 和 vue.js 一起使用,但我总是收到错误消息

uncaught exception: You must pass your app key when you instantiate Pusher.未捕获的异常:实例化 Pusher 时必须传递应用程序密钥。

i already created free pusher account and i posted my appkey at .env file我已经创建了免费的 pusher 帐户,并且我在 .env 文件中发布了我的 appkey

PUSHER_APP_ID=<REDACTED> PUSHER_APP_KEY=<REDACTED>
PUSHER_APP_SECRET=<REDACTED> PUSHER_APP_CLUSTER=eu

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

and at bootstrab.js i already created new echo instance and posted my pusher settings like this在 bootstrab.js 我已经创建了新的 echo 实例并像这样发布了我的推送器设置

import Echo from 'laravel-echo' window.Pusher = require('pusher-js');

window.Echo = new Echo({ broadcaster: 'pusher', key:process.env.MIX_PUSHER_APP_KEY, cluster:process.env.MIX_PUSHER_APP_CLUSTER, encrypted: true });

pusher.log=function(message) { window.console.log(message) }

can some body help to solve this issue please...请一些机构帮助解决这个问题...

This may be a problem in cache.这可能是缓存中的问题。

you can try你可以试试

php artisan optimize:clear

then然后

npm run dev

This solves problems about cache most of the time.这在大多数情况下解决了有关缓存的问题。

Note: Do not use config:cache after an optimize:clear because that would cache your current configuration.注意:不要在optimize:clear后使用config:cache ,因为这会缓存您当前的配置。 What we need in this situation is to clear everything in config cache so that a new config can be setup during build.在这种情况下,我们需要清除配置缓存中的所有内容,以便可以在构建期间设置新配置。

You should specify each variable on its own line.您应该在自己的行中指定每个变量。

I have also updated your question to remove the credentials.我还更新了您的问题以删除凭据。 You should creating a new app in the Pusher dashboard and remove the existing app to prevent unsolicited connections.您应该在 Pusher 仪表板中创建一个新应用程序并删除现有应用程序以防止未经请求的连接。 Once the new app is created you can use the new credentials as normal.创建新应用程序后,您可以照常使用新凭据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM