I'd like know what is the way to connect to redis using php from scratch (without use a client like predis)?
Thanks.
I'd like know what is the way to connect to redis using php from scratch (without use a client like predis)?
Thanks.
You can connect by using fsockopen
and communicate by sending raw commands and reading server response:
$c = fsockopen('127.0.0.1', 6379, $errCode, $errStr);
$rawCommand = "*2
\$4
Echo
\$12
hello world!
";
fwrite($c, $rawCommand);
$rawResponse = fgets($c);
echo $rawResponse; // $12
$rawResponse = fgets($c);
echo $rawResponse; // hello world!
To use it this way, you should get familiar with Redis protocol: http://redis.io/topics/protocol