安装Predis

时间:2017-09-11 12:04:29

标签: php redis

所以我开始学习Redis并尝试使用以下链接为PHP安装它: - https://github.com/nrk/predis

我是通过composer安装的,然后运行: -

require 'autoload.php';
$client = new Predis\Client(array('host' => "127.0.0.1", "port" => 6379, array("prefix" => "php:")));

$client->set("string:k", "something");

然而,这会产生错误: -

Fatal error: Uncaught Error: Class 'Predis\Configuration\Options' not found in /Library/WebServer/Documents/redis/2/src/Client.php on line 74

Error: Class 'Predis\Configuration\Options' not found in /Library/WebServer/Documents/redis/2/src/Client.php on line 74

这里有什么问题?

1 个答案:

答案 0 :(得分:0)

您必须像这样注册 Predis Autoloader

require __DIR__ . '/vendor/autoload.php'; //autoload vendor see https://getcomposer.org/doc/01-basic-usage.md#autoloading

$client = new Predis\Client(array('host' => "127.0.0.1", "port" => 6379, array("prefix" => "php:")));

$client->set("string:k", "something");