简体   繁体   中英

How do I install Predis on XAMPP windows?

I installed Predis on XAMPP windows machine using pearhub (pear install pearhub/predis). It installed without any error messages. But when I do the following

<?php
require "Predis.php";
$redis = new Predis/Client();
$redis->set('library', 'predis');
$value = $redis->get('library');
?>

It says Predis class not found. Any ideas how to properly install this on windows?

You need to install Redis first, and then Predis will work. Predis is only an interface for Redis.

Because you are on windows, you can find information in the executable here: https://github.com/dmajkic/redis/downloads

Also, I noticed in your code, you have this:

$redis = new Predis/Client();

It should be this:

$redis = new Predis_Client();

You need to start from folder, then paste following code in your php file.文件夹启动 ,然后将以下代码粘贴到 php 文件中。

<?php 
    require "predis/autoloader.php";
    Predis\Autoloader::register();
    $redis = new Predis\Client();
    $redis = new Predis\Client(array(
      "scheme" => "tcp",
      "host" => "127.0.0.1",
      "port" => 6379));
    if($redis)
    {
         echo "Redis connected succesfully";
    }
    else
    {
         echo "Redis Not connected";
    }
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM