title: How to check if redis server is running using Predis library in PHP
body: <p>I am integrating Redis cache with one of my website, I am using Predis as client side. I have created a static class for initializing.</p>
  
  <p>I need to check if the redis server is running or not. </p>
  
  <p>I have tried so many thins but it did not work, it is not able to catch the exception.</p>
  
  <p>My code is </p>
  
  <pre><code>public static function checkRedisConnection()
  {
      self::initialize();
      $client = new Predis\Client();
      try
      {
          $client-&gt;connect();
      }
      catch (Predis\Network\ConnectionException $exception)
      {
          exit("whoops, couldn't connect to the remote redis instance!");
      }
  
      $client-&gt;info();
  }
  </code></pre>
  
  <p>The above function in a class is not able to catch the error, instead it is showing the error on whole site.</p>
  
  <p>What to do in this situation?</p>