From e5211eaeb6c8d8a5a01a7c75286d51d22a029b4e Mon Sep 17 00:00:00 2001 From: Roman Samarsky Date: Mon, 22 Oct 2018 15:58:57 +0300 Subject: [PATCH 1/2] Removed predis from composer.json Added check on phpredis or predis availability --- pkg/redis/RedisConnectionFactory.php | 12 +++++++++--- pkg/redis/composer.json | 3 +-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/redis/RedisConnectionFactory.php b/pkg/redis/RedisConnectionFactory.php index e691810ff..72bd2e787 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 must be installed'); + } + $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", From f31f1d7817140355414b1a38553235da2290df9c Mon Sep 17 00:00:00 2001 From: Roman Samarsky Date: Mon, 22 Oct 2018 19:29:14 +0300 Subject: [PATCH 2/2] Changed exception message --- composer.json | 4 ++-- pkg/redis/RedisConnectionFactory.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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 72bd2e787..0a5bb80a7 100644 --- a/pkg/redis/RedisConnectionFactory.php +++ b/pkg/redis/RedisConnectionFactory.php @@ -102,7 +102,7 @@ private function createRedis(): Redis $this->redis = new PhpRedis($this->config); } else { if (false == class_exists(\Predis\Client::class)) { - throw new \LogicException('The package Predis must be installed'); + 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);