snc / SncRedisBundle

A Redis bundle for Symfony supporting Predis and PhpRedis

Home Page:https://github.com/snc/SncRedisBundle

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support predis 2.0

pesseyjulien opened this issue · comments

Hi,

It seems that upgrading to predis 2.0 is causing trouble.

I got this error when I tried :

! Symfony\Component\ErrorHandler\Error\ClassNotFoundError {#72
!! #message: """
!! Attempted to load class "Factory" from namespace "Predis\Profile".\n
!! Did you forget a "use" statement for e.g. "Predis\Command\Factory", "Predis\Connection\Factory", "JsonSchema\Constraints\Factory" or "Doctrine\DBAL\Driver\IBMDB2\Exception\Factory"?
!! """
!! #code: 0
!! #file: "./vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php"
!! #line: 170
!! trace: {
!! ./vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php:170 { …}
!! ./vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php:117 { …}
!! ./vendor/snc/redis-bundle/src/DependencyInjection/SncRedisExtension.php:68 { …}
!! ./vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php:76 { …}
!! ./vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php:42 { …}
!! ./vendor/symfony/dependency-injection/Compiler/Compiler.php:82 { …}
!! ./vendor/symfony/dependency-injection/ContainerBuilder.php:757 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:546 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:787 { …}
!! ./vendor/symfony/http-kernel/Kernel.php:128 { …}
!! ./vendor/bref/symfony-bridge/src/BrefKernel.php:62 { …}
!! ./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
!! ./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
!! ./vendor/symfony/console/Application.php:171 { …}
!! ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}
!! ./vendor/autoload_runtime.php:35 { …}
!! ./bin/console:12 {
!! ›
!! › require_once dirname(DIR).'/vendor/autoload_runtime.php';
!! ›
!! arguments: {
!! "/var/www/html/vendor/autoload_runtime.php"
!! }
!! }
!! }
!! }
!! 2022-06-08T18:33:11+00:00 [critical] Uncaught Error: Class "Predis\Profile\Factory" not found
!!

Best,
Julien

I've released 4.2.0 which declares conflict with predis 2.0 for the time being. I encourage somebody to work on proper support though. I don't use predis myself anymore, so this could otherwise take a while.

Try loading the new predis client in SncRedisExtension.php instead of profiles (they were removed in predis 2.0), here is an example

$profileId = sprintf('snc_redis.client.%s_profile', $client['alias']);
$clientDef = new Definition(\Predis\Client::class);
$clientDef->setPublic(false);
$container->setDefinition($profileId, $clientDef);

image

This will break everything if you have a custom configuration in the service container for the predis profiles, but if you were using a default configuration (like me) then this should do the job temporarily until a proper fix is released

Hi, thanks for looking into it. I ended up migrating to Phpredis anyway after finding out it's 6x time faster :)

finding out it's 6x time faster

Interesting, do you have some references to this? Or is it something purely internal? Any further info you could provide about this?

I might be interested in implementing support for Predis 2. It looks like it will be required to get rid of deprecation warnings with PHP 8.2.

Any guidelines on what an implementation might look like? Do we want to support both Predis 1 and 2, or would a major version bump to drop Predis 1 be acceptable?

We don't need to support both and major version bump depends on how much configuration changes, but I don't have issues with early major bump to get this support either