9951 explained code solutions for 126 technologies


predisHow do I install and configure a PHP Redis DLL on a Windows machine?


  1. Download the latest version of the PHP Redis DLL from PECL.
  2. Extract the php_redis.dll from the downloaded archive and place it in the ext folder of the PHP installation directory.
  3. Add the following line to the php.ini file: extension=php_redis.dll.
  4. Restart the web server.
  5. Test if the extension is loaded correctly by executing the following code:
<?php
$redis = new Redis();
if ($redis) {
    echo "Redis is working";
}

Output example

Redis is working

  1. Configure the Redis server connection by using the connect method:
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
  1. Verify the connection by using the ping method:
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo $redis->ping();

Output example

+PONG

Edit this code on GitHub