Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

dmitry.g.ivanov's avatar

Laravel Forge + Redis

How does Laravel Forge use Redis?

I've found redis-server and redis-tools installed via apt:

apt list --installed
...
redis-server/bionic,now 5:5.0.2-3chl1~bionic1 amd64 [installed]
redis-tools/bionic,now 5:5.0.2-3chl1~bionic1 amd64 [installed,automatic]

But I can't find redis php extension installed, neither in php -m, nor in php -i.

However, I've checked - it works somehow.

Also, does anyone know - Laravel Forge pre-install PhpRedis by default or not?

(Probably not because it should be seen in php -m and php -i as well?)

0 likes
11 replies
richard@gorbutt.com's avatar

From what I recall it just sat there running, and if you use it either in your code or as part of horizon (Queues) it connected (Hostname/Port was set in my .env file).

dmitry.g.ivanov's avatar

@gorby Yes, I use Redis on Forge too.

But I want to understand how does it work.

In order to use Redis locally, I have to install redis PHP extension.

But I can't see it installed on Forge. So, I wonder how does it work then?

1 like
dmitry.g.ivanov's avatar

@themsaid Thank you for your response!

Now I understand it.

We can use Redis with predis/predis OR with PhpRedis (which is "PHP Redis extension", it is the same).

I was confused by one of the projects where both were used in tests, so I thought that predis/predis required redis.so (and I supposed that PhpRedis is yet another extension), which is not true.

@themsaid What is the best practice for "requiring" predis/predis?

I mean, I don't need it on local environment, I need it only on production.

But Composer doesn't have something like require-prod...

So, I can "composer require" it and have loaded on every environment (which is not too bad but doesn't feel very clean...)

Or I can "composer require" it on production, but in that case, I would have unclear "git status" on production, which is worse for my eyes.

(As far as I know, there is no possibility to install the package without modifying the composer.json/composer.lock files.)

How do you handle that in your projects?

NAM's avatar

Hi. I too noticed that Larvel forge did not automatically install phpredis (php -m command shows no 'redis' listed, which is phpredis). This seems problematic (unless I am missing something?) because phpredis is the new default redis client (not predis). In fact, phpredis is also the recommended choice by Laravel.

NAM's avatar

Just an update - newly provisioned servers will have redis installed, but if you are like me and had some prior to these changes you should run these on your server:

pecl install redis

echo "extension=redis.so" > /etc/php/7.3/mods-available/redis.ini

sudo ln -s /etc/php/7.3/mods-available/redis.ini /etc/php/7.3/fpm/conf.d/30-redis.ini >/dev/null 2>&1;

sudo ln -s /etc/php/7.3/mods-available/redis.ini /etc/php/7.3/cli/conf.d/30-redis.ini >/dev/null 2>&1;

8 likes
eugenefvdm's avatar

@nam thank you! I installed my Forge server around a year ago and was super paranoid of automatic updates so never enabled them. Then this weekend the server acted up so I did apt-get upgrade and rebooted and this stabilized the server. However, redis stopped working. Your commands are spot on, in my case, for PHP 7.4

Please or to participate in this conversation.