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();
}
@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