yii-redis extension include(redis.php):无法打开流:没有这样的文件或目录


yii redis extention include(Redis.php): failed to open stream: No such file or directory

yii redis扩展http://www.yiiframework.com/extension/yii-redis/

        Yii::app()->redis->getClient()->set("myKey", "Your Value");
        echo Yii::app()->redis->getClient()->get("myKey"); // outputs "Your Value"
        Yii::app()->redis->getClient()->del("myKey"); // deletes the key

我得到错误:

include(Redis.php):无法打开流:没有这样的文件或目录

从扩展页面:

此程序包依赖于https://github.com/nicolasff/phpredisPHP扩展,请确保在继续之前已安装此插件。

我认为您只是安装了redis server而不是PHP extension for Redis。您必须为Redis安装PHP扩展,才能使您的PHP代码与Redis一起工作。

您可以使用此功能phpinfo()进行检查。如果你在输出信息中看到Redis,那么你就安装了它

要安装它,你可以看到:

  • https://github.com/nicolasff/phpredis/issues/213#issuecomment-11361242(用于Window)
  • http://raphaelstolt.blogspot.com/2010/05/installing-php-redis-extension-on-mac.html(用于MAC)
  • http://www.lecloud.net/post/3378834922/install-redis-php-extension-phpredis-with-macports

如果你使用的是类似Debian的操作系统(Ubuntu、Mint等),你应该试试:

sudo apt-get install redis-server php5-redis && sudo service apache2 restart

工作起来很有魅力!