Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symfony/console is listed in require-dev but it causes an error if it is not installed in prod env #726

Closed
mcutajar opened this issue Aug 14, 2024 · 1 comment
Labels
bug Not working as intended

Comments

@mcutajar
Copy link

Hi

We noticed for some reason that due to the RedisQueryCommand, the SncRedisBundle package seems to be requiring the symfony/console component despite declaring it as only required in dev.

NOTICE: PHP message: PHP Fatal error:  Uncaught Error: Class "Symfony\Component\Console\Command\Command" not found in /docroot/vendor/snc/redis-bundle/src/Command/RedisQueryCommand.php:24
172.25.0.2 -  14/Aug/2024:02:14:00 +0000 "GET /index.php" 500
Stack trace:
#0 /docroot/vendor/composer/ClassLoader.php(571): include()
#1 /docroot/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile()
#2 /docroot/vendor/snc/redis-bundle/src/Resources/config/services.php(30): Composer\Autoload\ClassLoader->loadClass()
#3 /docroot/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php(146): Symfony\Component\DependencyInjection\Loader\ProtectedPhpFileLoader::{closure}()
#4 /docroot/vendor/symfony/dependency-injection/Loader/PhpFileLoader.php(64): Symfony\Component\DependencyInjection\Loader\PhpFileLoader->executeCallback()
#5 /docroot/vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php(45): Symfony\Component\DependencyInjection\Loader\PhpFileLoader->load()
#6 /docroot/vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php(76): Snc\RedisBundle\DependencyInjection\SncRedisExtension->load()
#7 /docroot/vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php(42): Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass->process()
#8 /docroot/vendor/symfony/dependency-injection/Compiler/Compiler.php(80): Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass->process()
#9 /docroot/vendor/symfony/dependency-injection/ContainerBuilder.php(767): Symfony\Component\DependencyInjection\Compiler\Compiler->compile()
#10 /docroot/vendor/symfony/http-kernel/Kernel.php(506): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#11 /docroot/vendor/symfony/http-kernel/Kernel.php(771): Symfony\Component\HttpKernel\Kernel->initializeContainer()
#12 /docroot/vendor/symfony/http-kernel/Kernel.php(185): Symfony\Component\HttpKernel\Kernel->preBoot()
#13 /docroot/public/index.php(17): Symfony\Component\HttpKernel\Kernel->handle()
#14 /docroot/vendor/autoload_runtime.php(24): {closure}()
#15 /docroot/public/index.php(7): require_once('...')
#16 {main}
  thrown in /docroot/vendor/snc/redis-bundle/src/Command/RedisQueryCommand.php on line 24

here is some configuration from my project (although these are pretty basic):
snc_redis.yaml

snc_redis:
    clients:
        session_client:
            dsn: '%redis_session_dsn%'
            logging: 
            type: predis
            alias: session_client

framework.yaml

framework:
    session:
        handler_id: app.snc_redis.session

services.yaml

    app.snc_redis.session:
        class: 'Symfony\Component\HttpFoundation\Session\Storage\Handler\RedisSessionHandler'
        arguments: ['@snc_redis.session_client']

from my side I have experimented a bit with the services.php file
by surrounding the lines where the RedisQueryCommand is being injected into the container with the following:

if($configurator->env() == 'dev') { }  

However am not sure if this fits the best practice

thanks in advance!

@ostrolucky ostrolucky added the bug Not working as intended label Aug 14, 2024
@mcutajar
Copy link
Author

@ostrolucky Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Not working as intended
Projects
None yet
Development

No branches or pull requests

2 participants