-
Notifications
You must be signed in to change notification settings - Fork 35
/
SystemCheck.php
36 lines (29 loc) · 963 Bytes
/
SystemCheck.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* Matomo - free/libre analytics platform
*
* @link https://matomo.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\QueuedTracking;
use Piwik\Plugins\QueuedTracking\Queue\Backend\Redis;
class SystemCheck
{
public function checkRedisIsInstalled()
{
if (!class_exists('\Redis', false) || !extension_loaded('redis')) {
throw new \Exception('The phpredis extension is needed. Please check out https://github.com/nicolasff/phpredis');
}
}
public function checkConnectionDetails(Redis $backend)
{
if (!$backend->testConnection()) {
throw new \Exception('Connection to Redis failed. Please verify Redis host and port');
}
$version = $backend->getServerVersion();
if (version_compare($version, '2.8.0') < 0) {
throw new \Exception('At least Redis server 2.8.0 is required');
}
}
}