I discovered an issue with our Laravel project during a fresh installation. When I cloned the entire project and created the env file, I proceeded to install Sail containers and the existing Composer package file by executing the following command as per the official Sail documentation:
docker run --rm \
-u "$(id -u):$(id -g)" \
-v "$(pwd):/var/www/html" \
-w /var/www/html \
laravelsail/php82-composer:latest \
composer install --ignore-platform-reqs
After running the above command, I encountered this error message:
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi
Error
Class "Redis" not found
at vendor/laravel/framework/src/Illuminate/Redis/Connectors/PhpRedisConnector.php:81
77▕ * @throws \LogicException
78▕ */
79▕ protected function createClient(array $config)
80▕ {
➜ 81▕ return tap(new Redis, function ($client) use ($config) {
82▕ if ($client instanceof RedisFacade) {
83▕ throw new LogicException(
84▕ extension_loaded('redis')
85▕ ? 'Please remove or rename the Redis facade alias in your "app" configuration file in order to avoid collision with the PHP Redis extension.'
+19 vendor frames
20 [internal]:0
Illuminate\Foundation\Application::Illuminate\Foundation\{closure}(Object(Laravel\Telescope\TelescopeServiceProvider))
+5 vendor frames
26 artisan:35
Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1
I suspect that laravelsail/phpxx-composer image does not have the Redis extension installed, but I'm unsure how to address this issue.
For reference, the Laravel version is v10, we are using phpredis, and our PHP version is v8.2.
sail tinkerand putextension_loaded('redis')in it to check. See github.com/laravel/sail/issues/302 for a discussion of a similar issue in 8.0/8.1.