https://phpartisan.cn/news/35.html

laravel中我们可以很简单的使用Redis,如何在服务器安装Redis以及原创访问你们可以访问Ubuntu 设置Redis密码以及允许远程访问和在ubuntu 安装redis的简单方法就可以了,很多人在使用的时候常常出现Class 'Predis\Client' not found的错误,那是因为我们laravel没有安装Redis拓展包,好的,我们接下来安装使用Redis

composer.jsonrequire里输入

"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错误的更多相关文章

  1. 【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 ...

  2. 解决 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 解 ...

  3. _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 ...

  4. 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 ...

  5. _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 ...

  6. (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 ...

  7. 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 ...

  8. 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  搞 ...

  9. laravel5.7的redis配置,一直报错Class 'Predis\Client' not found

    laravel5.7的redis配置,一直报错Class 'Predis\Client' not found 首先我检查了配置,和composer 都没有错,用原生的redis也可以正常连接和读写. ...

随机推荐

  1. web前端学习(二)html学习笔记部分(3)--range对象

    1.2.8  html5编辑api之range对象(一) 1.2.8.1  Range 对象基本概念 Range 对象的基本概念,通过使用 Range 对象所提供的方法实现一个鼠标选取内容,通过点击按 ...

  2. DirectX11笔记(二)--Direct3D初始化1之基本概念

    原文:DirectX11笔记(二)--Direct3D初始化1之基本概念 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/u010333737/art ...

  3. Vue源码探究-数据绑定的实现

    Vue源码探究-数据绑定的实现 本篇代码位于vue/src/core/observer/ 在总结完数据绑定实现的逻辑架构一篇后,已经对Vue的数据观察系统的角色和各自的功能有了比较透彻的了解,这一篇继 ...

  4. 【水滴石穿】rn_statusbar

    先放项目地址https://github.com/hezhii/rn_statusbar 来看一下效果 咩有感觉很怎么样,看代码 根入口文件 //index.js //看代码我们知道入口是app.js ...

  5. 阿里云SaaS生态战略发布,用宜搭5分钟部署OCR文字识别

    7月26日,在阿里云合作伙伴峰会上,阿里云发布SaaS生态战略:通过SaaS加速器为合作伙伴提供应用开发.集成.上云.售卖的全链路解决方案,提升开发效率和集成效率,缩短商业化周期. 作为阿里SaaS加 ...

  6. LintCode刷题笔记-- O(1) Check Power of 2

    标签: 位运算 题目: Using O(1) time to check whether an integer n is a power of 2. 解题思路: 这道题是利用位运算判断一个数是不是2 ...

  7. node 写的简单爬虫(三)

    异步爬取数据 先引入 var async = require('async'); 然后同样上代码 var topicUrls = [];//存所有地址 http.get(url,function(re ...

  8. Linux进程管理(三、 线程)

    // ---- refer glibc, pthread_create.c ----// int __pthread_create_2_0 (newthread, attr, start_routin ...

  9. 生成主键ID,唯一键id,分布式ID生成器雪花算法代码实现

    工具类:  package com.ihrm.common.utils; import java.lang.management.ManagementFactory; import java.net. ...

  10. jQuery $.isNumeric vs. $.isNaN vs. isNaN

    在jQuery中,有几种方式可以判断一个对象是否是数字,或者可否转换为数字. 首先,jQuery.isNaN()在最新版本中已经被移除了(1.7之后),取而代之的是  jQuery.isNumeric ...