gpt4 book ai didi

php - 安装 Predis

转载 作者:可可西里 更新时间:2023-11-01 11:25:21 25 4
gpt4 key购买 nike

所以我刚开始学习 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

这里有什么问题吗?

最佳答案

你必须这样注册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");

关于php - 安装 Predis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46155341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com