laravel5.*安装使用Redis以及解决Class 'Predis\Client' not found和Fatal error: Non-static method Redis::set() cannot be called statically错误
https://phpartisan.cn/news/35.html
laravel
中我们可以很简单的使用Redis
,如何在服务器安装Redis以及原创访问你们可以访问Ubuntu 设置Redis密码以及允许远程访问和在ubuntu 安装redis的简单方法就可以了,很多人在使用的时候常常出现Class 'Predis\Client' not found的错误,那是因为我们laravel没有安装Redis拓展包,好的,我们接下来安装使用Redis
在composer.json
的require
里输入
"predis/predis": "^1.0"
然后更新一下
composer update
好的我们接下来在.env里配置一下我们的Redis路径
REDIS_HOST=你的IP
REDIS_PASSWORD=密码
REDIS_PORT=6379
好的,配置好了,接下来我们就是使用了
Redis::set('name', 'Taylor');
$test = Redis::get('name');
dd($test);
如果没问题,应该会输出"Taylor",如果出现如下报错,代表你的Redis链接错了
Connection refused [tcp://123.1.1.1:6379]
好的,现在我们就搞定了Redis的安装和使用
Redis扩展冲突导致:Fatal error: Non-static method Redis::keys() cannot be called statically
如果你是通过 PECL 安装 Redis PHP 扩展,则需要重命名 config/app.php 文件里的 Redis 别名。
方法1、在每个使用use Redis;
的文件中,我们改为use Illuminate\Support\Facades\Redis;
即可
方法2、在config/app.php
中的aliases
修改Redis
修改为Redisaa
这种别名,然后use Redisaa;
即可
laravel5.*安装使用Redis以及解决Class 'Predis\Client' not found和Fatal error: Non-static method Redis::set() cannot be called statically错误的更多相关文章
- 【laravel5.4】安装指定版本的predis 和 处理laravel5.*安装使用Redis以及解决Class 'Predis\Client' not found和Fatal error: Non-static method Redis::set() cannot be called statically错误
(predis下载地址:https://packagist.org/packages/predis/predis) 1.cmoposer 命令行: php composer require predi ...
- 解决 src/MD2.c:31:20: fatal error: Python.h: No such file or directory安装包错误
在linux命令行安装包时报错 src/MD2.c:31:20: fatal error: Python.h: No such file or directory 原因:缺少了python的dev 解 ...
- _mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':问题的解决 mysql安装python
在win7下安装了Python后,想安装python-MySQL,使用pip安装出现如下问题: >pip install MySQL-python _mysql.c(42) : fatal er ...
- python2用pip进行安装时报错Fatal error in launcher: Unable to create process using '"'
win7下python3和python2共存环境 用pip安装一个包执行pip2 install xxx的时候报错Fatal error in launcher: Unable to create p ...
- _mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':问题的解决
在win7下安装了python后,想安装python-mysql,使用pip安装出现如下问题: >pip install MySQL-python _mysql.c(42) : fatal er ...
- (Python mysql驱动的解决)_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':问题的解决
在win7下安装了Python后,想安装python-MySQL,使用pip安装出现如下问题: >pip install MySQL-python _mysql.c(42) : fatal er ...
- Python 安装MySQLdb模块遇到报错及解决方案:_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
一.问题 系统:win7 64位 在下载MySQL-python-1.2.5.zip,使用python setup.py install 安装时,出现以下报错: _mysql.c(42) : fata ...
- Fatal error: Call to a member function on a non-object 的2种解决办法
这两天被一个莫名其妙的错误:Fatal error: Call to a member function on a non-object in d://www/htdocs/inc.php 77 搞 ...
- laravel5.7的redis配置,一直报错Class 'Predis\Client' not found
laravel5.7的redis配置,一直报错Class 'Predis\Client' not found 首先我检查了配置,和composer 都没有错,用原生的redis也可以正常连接和读写. ...
随机推荐
- Direct2D 第6篇 绘制多种风格的线条
原文:Direct2D 第6篇 绘制多种风格的线条 上图是使用Direct2D绘制的线条,Direct2D在效率上比GDI/GDI+要快几倍,GDI/GDI+绘图是出了名的"慢", ...
- 2019-5-13-WPF-从触摸消息转触摸事件
title author date CreateTime categories WPF 从触摸消息转触摸事件 lindexi 2019-05-13 09:43:48 +0800 2019-05-12 ...
- POJ2082 Terrible Sets
Terrible Sets Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 5067 Accepted: 2593 Des ...
- PHP 中的 curl 函数发送 Post 请求应该注意的几点
public function http_request( $url, $post = '', $timeout = 5 ){ if( empty( $url ) ){return ;}$ch = c ...
- 遇到的bug
1 div出现莫名其妙的空白bug 之前写了一个后台管理系统,项目不小加上是改版,很多的js都是用的之前的, bug多到自己都不想看, 其中有个是用iframe 框架加载表格页面,但是右边跟下边出 ...
- jQuery动态加载动画spin.js
在线演示 本地下载
- NodeJS基础之Express路由和中间件
路由 路由是指如何定义应用的端点(URIs)以及如何响应客户端的请求. 路由是由一个 URI.HTTP 请求(GET.POST等)和若干个句柄组成,它的结构如下: app.method(path, [ ...
- 开通了第一个博客,mark一下!
今日上网查询了不同的博客,包括csdn.掘金等,最终决定选择博客园.打算待前端学完后,自己建立一个博客,这段时间内先用博客园记录学习过程.经常总结.更新,相信坚持学习一定可以找到好工作!
- python 文本文件的读取
- UVA_10055:Hashmat the brave warrior
Language:C++ 4.8.2 #include<stdio.h> int main(void) { long long int a, b; while(scanf("%l ...