不明白为什么安装了Yaconf插件,调用Yaconf类的时候,报错

来源:4-6 解读easyswoole进程以及redis的list

qq_十方_3

2020-04-08

  <?php

namespace AppLibRedis;


use EasySwooleConfig;
use EasySwooleCoreAbstractInterfaceSingleton;

class Redis
{
    use Singleton;

    public $redis = "";

    private function __construct()
    {

        if (!extension_loaded('redis')) {
            throw new Exception("redis.so文件不存在");
        }

        try {
            $this->redis = new Redis();

//            读取config.php
//            $redisConfig = Config::getInstance()->getConf("redis");
            $redisConfig =  Yaconf::get('redis');
//            var_dump($redisConfig);
            $result = $this->redis->connect($redisConfig['host'], $redisConfig['port'], $redisConfig['time_out']);
        } catch (Exception $e) {
//            throw new Exception($e->getMessage());
            throw new Exception('redis异常');
        }

        if ($result === false) {
            throw new Exception('redis 连接失败');
        }

    }

    public function get($key)
    {
        if (empty($key)) {
            return '';
        }
        return $this->redis->get($key);
    }
}


php.ini如下

运行

php easyswoole start

图片描述

图片描述

写回答

2回答

singwa

2020-04-09

你这个是报redis的错误

0
2
qq_十方_3
非常感谢!
2020-05-03
共2条回复

singwa

2020-04-09

//img1.sycdn.imooc.com/szimg/5e8e860e093c0b9b14620074.jpg

这个文件提示语法错误。你看看这个。

0
0

EasySwoole+ElasticSearch打造高性能小视频服务系统

系统掌握EasySwoole框架,从容应对高并发、高性能业务

556 学习 · 235 问题

查看课程