MacFJA / php-redisearch

PHP Client for RediSearch
MIT License
66 stars 9 forks source link

PHPRedis getClient only for v6+ #59

Open inpresif opened 1 year ago

inpresif commented 1 year ago

Unfortunately, as a windows user for local dev there's no such version yet (5.3 or so is highest).

This means that the line: $client = $clientFacade->getClient(new \Redis(['host', 6379])); will not work, as the construct expects 0 values.

Tried this:

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
$client = $clientFacade->getClient(new Redis($redis));

but that resolves to an error:

<br />
<b>Fatal error</b>:  Uncaught RedisException: Redis server went away in C:\Users\test.dev\redis\redisearch-macfja\vendor\macfja\redisearch\src\Redis\Client\PhpredisClient.php:53
Stack trace:
#0 C:\Users\test.dev\redis\redisearch-macfja\vendor\macfja\redisearch\src\Redis\Client\PhpredisClient.php(53): Redis-&gt;getOption(8)
#1 C:\Users\test.dev\redis\redisearch-macfja\vendor\macfja\redisearch\src\IndexBuilder.php(228): MacFJA\RediSearch\Redis\Client\PhpredisClient-&gt;execute(Object(MacFJA\RediSearch\Redis\Command\Create))
#2 C:\Users\test.dev\redis\redisearch-macfja\index.php(32): MacFJA\RediSearch\IndexBuilder-&gt;create(Object(MacFJA\RediSearch\Redis\Client\PhpredisClient))
#3 {main}
  thrown in <b>C:\Users\test.dev\redis\redisearch-macfja\vendor\macfja\redisearch\src\Redis\Client\PhpredisClient.php</b> on line <b>53</b><br />

Any tips?

MacFJA commented 1 year ago

I didn't try it, but you should be able to just give the $redis of your example instead of wrapping it into a new Redis client:

$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
// And any other commands needed to initialize the Redis client
// Like auth, setOption
$client = $clientFacade->getClient($redis);
inpresif commented 1 year ago

Thanks for the answer I appreciate that. I'll have a go at that, not sure if I tested that already.

Yesterday, I did install PRedis as well just to get ahead, then I realized redisearch is not supported for Windows either, so we're off to another issue to fix (probably Docker or in the worst case, develop on the server instead of locally).

Thanks again.