Published 2/3/2020 · 2 min read
Tags: laravel
Laravel Valet Installing PHPRedis with PECL/Homebrew
This post was written 3/2/2020 and explains how I got Redis working using Laravel Valet. Valet was a clean install following the instructions on the Laravel site.
I couldn’t get Predis to work (installed with composer) and the Laravel instructions suggest the following:
Before using Redis with Laravel, we encourage you to install and use the PhpRedis PHP extension via PECL. The extension is more complex to install but may yield better performance for applications that make heavy use of Redis.
Here are the steps I followed:
- Install Redis via Homebrew
brew install redis - The PHP version that you installed via the Laravel Valet instructions comes with PECL run
pecl install redis - Adjust your PHP configuration contained in
/usr/local/etc/php/7.4.2- remove the lineextension="redis.so"from the top ofphp.ini(your version of PHP may be different). - Create
/usr/local/etc/php/7.4.2/conf.d/ext-redis.iniand add:
[redis]
extension="/usr/local/Cellar/php/7.4.2/pecl/20190902/redis.so"
You will need to change 20190902 in the above path to the file directory number that you have on your file system, to find this navigate to /usr/local/Cellar/php/7.4.2/pecl/ and type ls this will show you the file path. Save the ext-redis.ini file and then restart Valet with valet restart and start and stop Redis with brew services using brew services stop redis and brew services start redis.
You should now be able to run Laravel Valet with Redis if you have Horizon installed then run php artisan horizon and check your queues run successfully.
Related Articles
- Deploying Your Laravel API and Vue SPA
Deploy your Vue 3 SPA on Vercel or Netlify while hosting the Laravel 11 API via Laravel Forge on Digital Ocean or Railway.
- Handling API Errors in Your Vue 3 SPA
How to handle validation errors, server errors, and network failures gracefully in a Vue 3 SPA consuming a Laravel API.
- Shaping API Responses with Laravel Resources
Laravel API resources provide fine-grained control over JSON responses, letting you transform models and include relationships consistently.