我正在使用 Laravel版本: 7.5, PHP版本: 7.4.8,服务器: APACHE(XAMPP),软件包: Redis,操作系统:Windows 10。
我已经在系统中安装了Redis,并且能够成功运行redis-server,但是当我在Laravel中使用它进行广播时,它将抛出以下错误:“请确保已安装并启用PHP Redis扩展” 。 Please find attached screenshot about error.
答案 0 :(得分:0)
您已安装Redis吗? https://redis.io/download
您的环境变量设置是什么?对于Redis:
BROADCAST_DRIVER=redis
QUEUE_CONNECTION=redis
QUEUE_DRIVER=redis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=secret
REDIS_PORT=6379
,您正在使用laravel回显服务器吗?您的laravel-echo-server设置是什么?
{
"authHost": "http://localhost",
"authEndpoint": "/broadcasting/auth",
"clients": [
{
"appId": "id",
"key": "key"
}
],
"database": "redis",
"databaseConfig": {
"redis": {
"password" : "secret"
},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": true,
"allowOrigin": "http://localhost:80",
"allowMethods": "GET, POST",
"allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
}
}
您是否启动了echo服务器并排队?使用以下
php artisan queue:work
laravel-echo-server start
还要安装predis / predis
答案 1 :(得分:0)
我发现答案将密钥添加到.env
文件中,如下所示:
REDIS_CLIENT=predis