Jan 5, 2022
0
Level 7
Guide: Making Redis & Horizon work with Sail
Recording for posterity, since this info is not in one place in the documentation and it can take a while to figure out why Redis & Horizon are not working with Sail.
Assuming you have the default Sail+redis container setup:
- first, there's no need to install
predis/predis. I see this used as a workaround in many answers when in reality what you are doing is bypassing sail.
So, to get everything working using Sail proper:
- go to
config/app.phpand un-comment the Redis alias so you don't get 'class not found' - in
.env, addREDIS_HOST=redisso that it points to the Sail redis container - in
.env, add/change toQUEUE_CONNECTION=redis - refresh cache
php artisan config:cache - start the horizon server
php artisan horizon - now visit
localhost.test/horizonand you should see the Horizon dashboard and the 'Status' box should indicate Active.
You can do a quick code test, eg do a Redis::set('name', 'Taylor'); in Tinker and then you can even connect to the Redis DB using something like TablePlus and will see the data saved in the Redis db.
Hope it helps someone avoid the run-around to get this working.
Please or to participate in this conversation.