Skip to content

Instantly share code, notes, and snippets.

@mtvbrianking
Last active June 6, 2024 11:46
Show Gist options
  • Save mtvbrianking/eb7e1dc54d4b85a0a3f27c21fe4d654f to your computer and use it in GitHub Desktop.
Save mtvbrianking/eb7e1dc54d4b85a0a3f27c21fe4d654f to your computer and use it in GitHub Desktop.
Install Redis on Xampp - Windows

Redis

Linux

jdoe@home-pc:~# apt-get install redis-server
jdoe@home-pc:~# systemctl enable redis-server@.service
jdoe@home-pc:~# apt-get update
jdoe@home-pc:~# apt-cache pkgnames | grep php7.4
jdoe@home-pc:~# apt install php7.4-redis
jdoe@home-pc:~# service apache2 restart
jdoe@home-pc:~# redis-cli

https://redis.io/download#installation

https://tecadmin.net/install-redis-ubuntu

Windows

Download

https://github.com/tporadowski/redis/releases

Tutorial

https://www.c-sharpcorner.com/article/installing-redis-cache-on-windows

Xampp

https://www.phpflow.com/php/how-to-setup-redis-server-and-use-with-php

  • Download php_redis.dll file from PECL libs. Download extension as per your current PHP version.
  • Copy the php_redis.dll and paste to following folder in XAMPP Server extension directory(D:\XAMPP\php\ext).
  • Open the php.ini file and add extension=php_redis.dll line into this file.
  • Restart XAMPP server
  • Open phpinfo() of XAMPP server and search Redis, if found that means you successfully integrated Redis with PHP.

Usage

<?php

try {
    // create redis instance
    $redis = new \Redis();
    
    // connect with server and port
    $redis->connect('localhost', 6379);
    
    // set key
    $redis->set('user', 'John Doe');
    
    // get value
    $user = $redis->get('user');

    print($user); // John Doe
} catch (Exception $ex) {
    echo $ex->getMessage();
}
@shivam-aisect
Copy link

PECL libs don't have dll for >5.6 PHP Versions.

@mtvbrianking
Copy link
Author

Since I can't recreate your environment so it's near impossible for me to debug. Sorry

@catwhocode
Copy link

thank you, works fine on xampp 8.0.11 using phpredis 5.3.4 x64 dll

to make life easier, I download Redis Desktop Manager

@hashimaziz1
Copy link

The XAMPP section is patently wrong and only enables the php_redis extension - without some sort of binary that packages redis-server there's nothing to connect to and it will result in the "No connection..." error described above. The unofficial binaries listed in the Windows section are at 2 major versions out of date and counting. It boggles my mind that the Redis devs haven't bothered to create an official binary for Windows when it's the most widely used platform for local development by a large margin.

@muhammad20620
Copy link

muhammad20620 commented Jun 6, 2024

im getting frustrated cant get redis to work with laravel horizon php-8.3 xampp. Any suggestion

@hashimaziz1
Copy link

im getting frustrated cant get redis to work with laravel horizon php-8.3 xampp. Any suggestion

Can't help with the Horizon part but I wrote this for getting Redis set up with XAMPP a few months ago, it might help:

https://stackoverflow.com/questions/77347654/how-do-i-install-redis-and-the-phpredis-extension-in-laravel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment