predisHow do I install and configure a PHP Redis DLL on a Windows machine?
- Download the latest version of the PHP Redis DLL from PECL.
- Extract the
php_redis.dll
from the downloaded archive and place it in theext
folder of the PHP installation directory. - Add the following line to the
php.ini
file:extension=php_redis.dll
. - Restart the web server.
- Test if the extension is loaded correctly by executing the following code:
<?php
$redis = new Redis();
if ($redis) {
echo "Redis is working";
}
Output example
Redis is working
- Configure the Redis server connection by using the
connect
method:
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
- Verify the connection by using the
ping
method:
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo $redis->ping();
Output example
+PONG
More of Predis
- How can I use the zscan command in PHP with Redis?
- How can I set a timeout for a Redis connection using PHP?
- How do I set the retry interval for a PHP application using Redis?
- How can I list keys in Redis using PHP?
- How do I use Redis Lock in a PHP application?
- How do I install Predis on Ubuntu using PHP?
- How can I use PHP and Redis to retrieve data from a sorted set using ZRANGEBYSCORE?
- How can I use PHP to increment values in Redis using ZINCRBY?
- How do I install PHP, Redis, and XAMPP?
See more codes...