0

I am trying to implement an PHPUnit integration-test for a Controller. Within the controller I instantiate an Object of the PHPRedis-class (https://github.com/phpredis/phpredis#usage):

//connect to redis database try { $this->objPHPRedis = new \Redis(); $this->objPHPRedis->connect('127.0.0.1'); } catch(\RedisException $e) { $this->log($e, 1); } catch (\Exception $e) { $this->log($e, 1); }

This works great when I process normal requests, but it fails when I execute the test:

PHP Fatal error: Class Redis not found in /var/www/.../MyController.php on line 100.

I have no idea where to start searching for the problem. Does anybody have an idea what the problem could be?

Niklas
  • 95
  • 1
  • 9

1 Answers1

1

Your CLI config for php has the redis module not loaded. Find your CLI php.ini, probably named cli_php.ini or something similar and make sure your redis module is loaded there as well.

floriank
  • 25,546
  • 9
  • 42
  • 66