Laravel Deployment Issue - Class "Redis" Not Found in PhpRedisConnector.php

valehasadliHOBBY

a year ago

Hello there,

I'm currently facing an issue with my Laravel application during deployment, specifically related to the Redis extension. The error message I'm encountering is:

Error: Class "Redis" not found in file /app/vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php on line 79

It's worth mentioning that everything works fine in local development using the Sail package, but the problem arises when deploying the application. I suspect that the Redis extension might not be installed during the deployment process with Nixpack.

I've attempted to address the issue by adding NIXPACKS_PKGS env variable with php82Extensions.redis, but unfortunately, it did not resolve the problem.

I'm seeking guidance on how to fix this issue without resorting to a custom Dockerfile. Any insights or suggestions would be greatly appreciated.

Thank you in advance for your help!

1 Replies

lolautrucheTRIAL

8 months ago

Hello

To get PHP extensions installed, you need to add them to the "require" section of your composer.json, like described in Composer doc: https://getcomposer.org/doc/articles/composer-platform-dependencies.md#different-types-of-platform-packages. For the Redis extension, use ext-redis. I have an example here: https://github.com/lolautruche/smoobu-bookings-symfony/blob/main/composer.json#L10

FWIW, I opened a PR on Nixpacks doc to clarify this topic: https://github.com/railwayapp/nixpacks/pull/1169


Laravel Deployment Issue - Class "Redis" Not Found in PhpRedisConnector.php - Railway Help Station