Created an event, it works locally, uploaded it to the server stopped working.
[2021-04-02 14:26:51] local.ERROR: Class ‘Redis’ not found {"exception":"[object] (Error(code: 0): Class ‘Redis’ not found at /vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:75)[stacktrace]
how to connect Redis?
PrivatMessageEvent.php
<?php
namespace AppEvents;
use IlluminateBroadcastingChannel;
use IlluminateBroadcastingInteractsWithSockets;
use IlluminateBroadcastingPresenceChannel;
use IlluminateBroadcastingPrivateChannel;
use IlluminateContractsBroadcastingShouldBroadcast;
use IlluminateFoundationEventsDispatchable;
use IlluminateQueueSerializesModels;
class PrivatMessageEvent implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $data;
/**
* Create a new event instance.
*
* @return void
*/
public function __construct($data)
{
$this->data = $data;
}
/**
* Get the channels the event should broadcast on.
*
* @return IlluminateBroadcastingChannel|array
*/
public function broadcastOn()
{
return new Channel('private-channel');
}
}
When I start the queue, I can see that this event is in progress but gives an Failed.
Script blade template
socket.on("private-channel:App\Events\PrivatMessageEvent", function (message) {
appendMessageToReceiver(message);
});
configbd
'redis' => [
'client' => env('REDIS_CLIENT', 'phpredis'),
'cluster' => false,
'default' => [
'host' => env('REDIS_HOST', '127.0.0.1'),
'database' => 0,
'port' => env('REDIS_PORT', '6379'),
]
]
2
Answers
Can you verify you’ve got the phpredis extension installed and enabled?
Please check the introduction section in the Laravel docs: https://laravel.com/docs/8.x/redis#introduction
You should install redis package for the php version being used.
If your php version is 8.0 then