9951 explained code solutions for 126 technologies


predisHow do I install Predis on Ubuntu using PHP?


To install Predis on Ubuntu using PHP, you will need to have Composer installed.

  1. Run the following command in your terminal to install Predis:
composer require predis/predis
  1. After the installation is complete, you will need to add the following line of code to your php.ini file:
extension=predis.so
  1. Finally, you will need to restart your web server in order for the changes to take effect.

  2. To test if Predis is installed correctly, you can run the following code in your terminal:

<?php
$client = new Predis\Client();
$client->set('foo', 'bar');
$value = $client->get('foo');
echo $value;

The output of the code should be bar.

  1. You can also refer to the Predis documentation for more information.

  2. You can also refer to the Predis installation guide for more detailed instructions.

  3. You can also refer to the PHP manual for more information.

Edit this code on GitHub