phpmacosredisxampp

Install PHP-Redis for XAMPP on Mac


XAMPP 7.3 is installed and functional and localhost is working as expected. Now I would like to install PHP-Redis to test Redis.

I've been following the instructions here: https://www.9lessons.info/2016/12/install-xampp-70-on-ubuntu-and-mac-osx.html

So, I have installed PHP-Redis:

$ brew install homebrew/php/php70
$ brew install homebrew/php/php70-redis

I have then edited php.ini in the XAMPP directory (/Applications/XAMPP/xamppfiles/etc/php.ini), and added the following line:

extension="redis.so"

After restarting XAMPP, Redis is not recognized in phpinfo(), and trying to set a Redis class results in Fatal error: Uncaught Error: Class 'Redis' not found in /Applications/XAMPP/xamppfiles/htdocs/test/redis_cache_test.php

I have also tried in php.ini:

extension=/‎⁨usr⁩/local⁩⁨/Cellar⁩/php70⁩/7.0.19_11⁩/lib⁩⁨/php⁩/⁨extensions⁩/⁨no-debug-non-zts-20151012⁩/redis.so

However, the Redis plugin does not appear to be loading, where am I going wrong on this installation?


Solution

  • I have found the solution for XAMPP on Mac:

    1. Open Terminal
    2. Change directory to XAMPP: cd /Applications/XAMPP/bin
    3. Install Redis using PECL: sudo ./pecl install redis
    4. Add extension to php.ini: extension="redis.so"
    5. Restart PHP, the Redis plugin should be visible from phpinfo()