Install Redis & Redis extension in PHP on windows

This article is intended to those who wish to install Redis and PHP extension for interfacing with Redis on their XAMPP installation on windows. As I had required once to setup a Redis Server on my local development machine and utilize it as it was not possible to test on a production environment. 

Redis is more than just a in-memory caching system and is popular choice among developers because of persistence storage and versatile features provided by it. Redis runs as a separate service and is called by any other process including PHP. You can simply think it as relation like PHP – MySQL relation. To handle communication between Redis service and the process, Redis clients are introduced. predis and phpredis are two very popular and regularly maintained Redis clients for PHP, former is a PEAR package and latter is a PECL extension.

PHP Extension Community Library or PECL, are simply packages written in C and further compiled into a .dll for windows. These .dll files are kept into php/ext directory and we need to add an entry into php.ini in order to use the particular package.

PEAR on another hand, is PHP Extension and Application Repository, consisting a number of php files, available to be used by the end user just like other normal php file which are integrated into your project through autolaoding or included by you manually. In trend with time, installing these package using Packagist with Composer is preferred which also facilitate dependency management and PEAR is less favorable.

There is too less support present for Redis in windows operating system as compared to linux operating system. It is always wise to install Redis Server locally first, then install Redis client and setup your script to communicate with this server to test basic functionalities in your system. Without a clear documentation and support, it’s very difficult to make Redis server up and working with it in windows machine. So here in this article, you will find how easy is to setup and use Redis with PHP on a windows system.

Install Redis & Redis extension in PHP on XAMPP on windows

First of all we will install Redis then PECL extension for PHP step by step.

Step 1:

Download and install Redis service using either of the given options. Regardless of download and installation method you select, you must have to ensure that the Redis service is running on the system after installation:

(i)  Redis for windows(x64) –

(ii) Redis for windows(x86) – 

(iii) Linux version of Redis on windows using Vagrant –

I am using the second option. It also needs a machine restart after installation to let Redis server run. Install Redis service as a windows service which is asked during installation process to automatically start Redis on system boot each time.

If your Redis service is installed and running you can test it by running Redis Client tool in your installation folder which is basically a command line tool. On the command line you will see something like this:

Redis and extension in PHP

On the command prompt type ping and press enter, then you will see PONG as result if your Redis server is running.

Step 2:

This step involves to download and setup an extension in PHP to communicate with Redis Server. I’m using PECL extension. You can also use PEAR extension (using composer) if you prefer as I have already mentioned difference between them.

Download PECL extension (DLL file) from

But before this you need to know which PHP version have you installed and whether thread safety is enabled or not. To know that, use phpinfo() function in a PHP file and access the file on browser using localhost. You will see PHP installation information where you can check for version and thread safety.

For thread safety enabled system, download ts version of dll according to your PHP version and system architecture (x86/x64) otherwise use nts version. Extract the contents and copy the .dll file in xampp/php/ext directory.

Next, browse the xampp/php folder, edit php.ini file located there and add string extension="php_redis.dll" along with other extensions and restart your apache server.

Now it’s time to check. Write the code below in a php file, save it and access in browser. If everything is done as described, you will see dolly as output:

So give it a try and let me  know your experience about installing Redis & Redis extension in PHP on XAMPP on windows.


  1. Prathamesh Sarang says:

    Not working for me ..did everything as mentioned.
    A doubt, there are many files in the zip so all of them needs to be copied or just the dll one?

    1. Amit Sonkhiya says:

      @disqus_bTjkvTf0Uw:disqus just try to install only Redis first .
      Check if Redis service installed & listed in Control Panel > Administrative Tools > Services
      In windows you need to copy dll one only.

      Also check for @arungisyadi:disqus ‘s comment, I have not tested it.

  2. arungisyadi says:

    One thing need to take note here… If using XAMPP, despite that you’re using X64 processor. The PECL library still need to use X86. This is because XAMPP doesn’t have environment for x64.
    Just hope this helps anyone having trouble installing redis for PHP.


Leave a Reply

Enclose a code block like: <pre><code>Your Code Snippet</code></pre>.