Home / Tutorials / Installing PHPRedis on MacOS
Installing PHPRedis on MacOS cover

Installing PHPRedis on MacOS

15 mins


3 years ago



When working with Redis in Laravel, they are encouraged to install PHPRedis extension via PECL. This extension is the new recommended over the old predis/predis package as it's no longer maintained and it's more performant.

Installing Laravel Valet

I am making use of Laravel Valet to run my Laravel locally and after a fresh install, I went and right away install Redis using Homebrew (make sure to have it installed).
To install Redis, run the following command.
brew install Redis
Next, make sure to start Redis and restart Laravel Valet.
brew services start redis

valet restart
Now when you run brew services list you will be able to see Redis running on your machine.

Installing PHPRedis

To install PHPRedis we have to use PECL which is a PHP extension repository and to do so run the command below.
pecl install redis
Once it's installed we have to update our php.ini and since we are installing the PHP via Homebrew, the location will be in /usr/local/etc/php/[your-php-version].

Inside the php.ini file, remove extension="redis.so" and we'll have to create ext-redis.ini inside the conf.d directory.

Inside the ext-redis.ini you need to provide the Redis extension path and it will look like below.
Once you have defined that, save it and restart PHP via Laravel Valet valet restart.

Add PHPRedis to your Laravel Application

The next step is to add phpredis into your laravel environment variable and we can do this by defining this config.
By now you will have the extension and package installed and if you are using Laravel Horizon you can run php artisan horizon and your queue will start being processed.

Update *2 March 2020*

Do note that depending on the version of brew you installed, the location has moved to a different directory.
notion avatar

Ahmad Aziz

Week-end developer currently experimenting with web, mobile, and all things programming.


Ahmad Aziz

1 week ago

Loving this redis tutorial!

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Related Tutorials

Code Snippets

Collection of Laravel, AlpineJS, VueJS, Tailwind CSS, Flutter snippets and more. New snippets added every day.
View Snippets

Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that's right for your web projects
View Components

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this