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也可以正常连接和读写. ...
随机推荐
- HDU 3555 (递推&&记忆化)
#include<stdio.h> #include<string.h> #define max 25 typedef __int64 LL; LL dp[max][]; // ...
- 【JZOJ5060】【GDOI2017第二轮模拟day1】公路建设 线段树+最小生成树
题面 在Byteland一共有n 个城市,编号依次为1 到n,它们之间计划修建m条双向道路,其中修建第i 条道路的费用为ci. Byteasar作为Byteland 公路建设项目的总工程师,他决定选定 ...
- Codeforces Round #192 (Div. 2) A. Cakeminator【二维字符数组/吃掉cake,并且是一行或者一列下去,但是该行/列必须没有草莓的存在】
A. Cakeminator time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- 使用Webpack的代码分离实现Vue懒加载
当一个Vue的项目体积变得十分庞大的时候,使用Webpack的代码分离功能将Vue Components,routes或Vuex的代码进行分离并按需加载,会极大的提高App的首屏加载速度. 在Vue的 ...
- Intellij IDEA通过tomcat部署web项目的机制
问题 以前使用eclipse调用tomcat运行web项目时,eclipse的方式非常直接了当,就是直接将项目更新到%TOMCAT_HOME%/webapps目录下即可.然而在使用Intellij I ...
- @hdu - 6687@ Rikka with Stable Marriage
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个稳定婚姻匹配问题,其中第 i 个男生与第 j 个女生之间 ...
- Spring Boot错误——SpringBoot 2.0 报错: Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
背景 使用Spring Cloud搭建微服务,服务的注册与发现(Eureka)项目启动时报错,错误如下 *************************** APPLICATION FAILED T ...
- LeetCode110 Balanced Binary Tree
Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary ...
- JavaScriptBreak 语句 continue 语句
break 语句用于跳出循环. continue 用于跳过循环中的一个迭代. Break 语句 我们已经在本教程之前的章节中见到过 break 语句.它用于跳出 switch() 语句. break ...
- js获取屏幕相关值
<html><script>function a(){document.write("屏幕分辨率为:"+screen.width+"*" ...