diff --git a/composer.json b/composer.json index 266a9e326..0099b6cac 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,8 @@ "stomp-php/stomp-php": "^4", "php-http/guzzle6-adapter": "^1.1", "php-http/client-common": "^1.7@dev", - "richardfullmer/rabbitmq-management-api": "^2.0" + "richardfullmer/rabbitmq-management-api": "^2.0", + "predis/predis": "^1.1" }, "require-dev": { "phpunit/phpunit": "^5.5", @@ -48,7 +49,6 @@ "empi89/php-amqp-stubs": "*@dev", "doctrine/doctrine-bundle": "~1.2", "kwn/php-rdkafka-stubs": "^1.0.2", - "predis/predis": "^1.1", "friendsofphp/php-cs-fixer": "^2" }, "autoload": { diff --git a/pkg/redis/RedisConnectionFactory.php b/pkg/redis/RedisConnectionFactory.php index e691810ff..0a5bb80a7 100644 --- a/pkg/redis/RedisConnectionFactory.php +++ b/pkg/redis/RedisConnectionFactory.php @@ -94,11 +94,17 @@ public function createContext(): Context private function createRedis(): Redis { if (false == $this->redis) { - if (in_array('predis', $this->config['scheme_extensions'], true)) { - $this->redis = new PRedis($this->config); - } elseif (in_array('phpredis', $this->config['scheme_extensions'], true)) { + if (in_array('phpredis', $this->config['scheme_extensions'], true)) { + if (false == class_exists(\Redis::class)) { + throw new \LogicException('You must install the redis extension to use phpredis'); + } + $this->redis = new PhpRedis($this->config); } else { + if (false == class_exists(\Predis\Client::class)) { + throw new \LogicException('The package "predis/predis" must be installed. Please run "composer req predis/predis:^1.1" to install it'); + } + $this->redis = new PRedis($this->config); } diff --git a/pkg/redis/composer.json b/pkg/redis/composer.json index 878bc9cd5..dfbccfd04 100644 --- a/pkg/redis/composer.json +++ b/pkg/redis/composer.json @@ -8,8 +8,7 @@ "require": { "php": "^7.1.3", "queue-interop/queue-interop": "0.7.x-dev", - "enqueue/dsn": "0.9.x-dev", - "predis/predis": "^1.1" + "enqueue/dsn": "0.9.x-dev" }, "require-dev": { "phpunit/phpunit": "~5.4.0",