6 protected $deps = array(
7 'pear.php.net/VersionControl_Git' => 'VersionControl_Git',
8 'pear.twig-project.org/Twig' => 'Twig_Autoloader',
9 'pear.php.net/Date_HumanDiff' => 'Date_HumanDiff',
10 'pear.php.net/HTTP_Request2' => 'HTTP_Request2',
11 'pear.php.net/OpenID' => 'OpenID',
12 'pear.php.net/Pager' => 'Pager',
13 'pear.php.net/Services_Libravatar' => 'Services_Libravatar',
14 'zustellzentrum.cweiske.de/MIME_Type_PlainDetect' => 'MIME_Type_PlainDetect',
17 protected $writableDirs;
18 protected $elasticsearch;
20 public function __construct()
22 $cfg = $GLOBALS['phorkie']['cfg'];
23 $this->writableDirs = array(
24 'gitdir' => $cfg['gitdir'],
25 'workdir' => $cfg['workdir'],
27 $this->elasticsearch = $cfg['elasticsearch'];
30 public static function run()
39 public function checkDeps()
41 foreach ($this->deps as $package => $class) {
42 if (!class_exists($class, true)) {
43 $this->fail('PEAR package not installed: ' . $package);
48 public function checkDirs()
50 foreach ($this->writableDirs as $name => $dir) {
52 $this->fail($name . ' directory does not exist at ' . $dir);
54 if (!is_writable($dir)) {
55 $this->fail($name . ' directory is not writable at ' . $dir);
60 public function checkGit()
62 $line = exec('git --version', $lines, $retval);
64 $this->fail('Running git executable failed.');
66 if (!preg_match('#^git version ([0-9.]+)$#', $line, $matches)) {
67 $this->fail('git version output format unexpected: ' . $line);
69 if (version_compare($matches[1], '1.7.5') < 0) {
71 'git version needs to be at least 1.7.5, got: ' . $matches[1]
76 public function checkDatabase()
78 if ($this->elasticsearch == '') {
82 $es = parse_url($this->elasticsearch);
83 if (!preg_match("#/.+/#", $es['path'], $matches)) {
85 'Improper elasticsearch url. Elasticsearch requires a'
86 . ' search domain to store your data.'
87 . ' (e.g. http://localhost:9200/phorkie/)'
90 $dbs = new Database();
91 $dbs->getSetup()->setup();
94 public function fail($msg)
96 throw new Exception($msg);