回答:我不得不将PREDIS_BASE_PATH的路径更改为predis/lib/。
我想在PHP文件中加载predis,但是我遇到了麻烦。我是按照指南加载predis网站(https://github.com/nrk/predis)的predis。下面是我用来加载predis的代码:
define("PREDIS_BASE_PATH", "predis/");
echo "The predis base path is: " . PREDIS_BASE_PATH . "\n";
spl_autoload_register(function($class) {
$file = PREDIS_BASE_PATH . strtr($class, '\\', '/') . '.php';
echo "The file variable is: " . $file . "\n";
if (file_exists($file)) {
require $file;
return true;
}
});
$redis = new Predis\Client(array(
'host' => 'localhost',
'port' => 6379,
));下面是我得到的错误:
Fatal error: Class 'Predis\Client' not found编辑:应该导入predis目录中的哪个文件?更改文件夹权限后,我可以回显变量$file持有的内容:“文件变量是: predis/Predis/Client.php”
根据这里列出的目录,https://github.com/nrk/predis,没有client.php文件。
发布于 2012-07-20 06:40:00
我使用下面的代码连接php页面上的predis,它工作得很好。下面是代码
<?php
require "predis/autoloader.php";
Predis\Autoloader::register();
$redis = new Predis\Client(array(
"scheme" => "tcp",
"host" => "127.0.0.1",
"port" => 6379));
?>发布于 2015-09-21 12:31:42
编写以下代码调用寄存器方法:
Predis\Autoloader::register();而不是PredisAutoloader::register();
并将您的测试文件并行到Predis文件夹。
发布于 2011-06-29 00:01:07
$redis = new Predis\Client(array(应该是
$redis = new Predis_Client(array(https://stackoverflow.com/questions/6514108
复制相似问题