请确保在.larave7中安装并启用了php redis扩展?

7uhlpewt  于 2021-06-10  发布在  Redis
关注(0)|答案(0)|浏览(257)

我正在尝试为聊天组创建状态通道,我设置了redis,每件事都是必需的,但无论我如何运行都会出现此错误
composer 需要predis/predis
并使用laravel echo sever。我创建事件以侦听聊天应用程序和此代码消息事件:

class Message implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
/**
 * Create a new event instance.
 *
 * @return void
 */
public function __construct( \App\Message $message)
{
     $this->message=$message;
     //dd();
}

/**
 * Get the channels the event should broadcast on.
 *
 * @return \Illuminate\Broadcasting\Channel|array
 */
public function broadcastOn()
{
    return new Channel('chat-group');
}
}

消息控制器:

public function store(Request $request){
    $m=new Message();
    $m->content=$request->message;
    $m->user_id=Auth::id();
    $m->save();
    broadcast(new \App\Events\Message($m))->toOthers();
}

应用程序js:

window.Echo.channel('chat-group')
.listen('Message', (e) => {
    console.log(e.message.content);
});

d:\work\chat>redis cli ping pong结果:

{
"message": "Please make sure the PHP Redis extension is installed and enabled.",
"exception": "LogicException",
"file": 
]
}

环境:

BROADCAST_DRIVER=redis
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_CLIENT=predis
REDIS_PASSWORD=null
REDIS_PORT=6379

laravel回音服务器:

L A R A V E L  E C H O  S E R V E R

 version 1.6.2

 ⚠ Starting server in DEV mode...

  ✔  Running at localhost on port 6001
  ✔  Channels are ready.
  ✔  Listening for http events...
  ✔  Listening for redis events...

  Server ready!

  [1:04:07 PM] - Preparing authentication request to: http://localhost:8000
  [1:04:07 PM] - Sending auth request to: http://localhost:8000/broadcasting/auth

  [1:04:07 PM] - fZvJEifYevcj805nAAAA joined channel: chat-group
   [1:04:07 PM] - fZvJEifYevcj805nAAAA authenticated for: presence-online
  [1:04:07 PM] - fZvJEifYevcj805nAAAA joined channel: presence-online
  [1:04:08 PM] - Preparing authentication request to: http://localhost:8000
  [1:04:08 PM] - Sending auth request to: http://localhost:8000/broadcasting/auth

  [1:04:08 PM] - kif6o7whupgU9GH2AAAB joined channel: chat-group
  [1:04:08 PM] - kif6o7whupgU9GH2AAAB authenticated for: presence-online
  [1:04:08 PM] - kif6o7whupgU9GH2AAAB joined channel: presence-online

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题