Skip to content

Commit

Permalink
Removed predis from composer.json
Browse files Browse the repository at this point in the history
Added check on phpredis or predis availability
  • Loading branch information
rosamarsky committed Oct 22, 2018
1 parent 26dae59 commit 6c9148b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 9 additions & 3 deletions pkg/redis/RedisConnectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/redis/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 6c9148b

Please sign in to comment.