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.dllfrom the downloaded archive and place it in theextfolder of the PHP installation directory. - Add the following line to the
php.inifile: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
connectmethod:
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
- Verify the connection by using the
pingmethod:
<?php
$redis = new Redis();
$redis->connect('127.0.0.1', 6379);
echo $redis->ping();
Output example
+PONG
More of Predis
- How can I troubleshoot a "PHP Redis went away" error?
- How can I use PHP and Redis to retrieve data from a sorted set using ZRANGEBYSCORE?
- How do I install PHP Redis on Ubuntu 20.04?
- How can I check the version of PHP and Redis I am using?
- How can I configure TLS encryption for a connection between PHP and Redis?
- How do I use PHP to subscribe to Redis?
- How do I set an expiration time for a Redis key using PHP?
- How do I use a Redis message queue with PHP?
- How can I use the zscan command in PHP with Redis?
See more codes...