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 'pear2.php.net/Services_Linkback' => '\\PEAR2\\Services\\Linkback\\Client',
15 'zustellzentrum.cweiske.de/MIME_Type_PlainDetect' => 'MIME_Type_PlainDetect',
18 protected $writableDirs;
19 protected $elasticsearch;
21 public function __construct()
23 $cfg = $GLOBALS['phorkie']['cfg'];
24 $this->writableDirs = array(
25 'gitdir' => $cfg['gitdir'],
26 'workdir' => $cfg['workdir'],
28 $this->elasticsearch = $cfg['elasticsearch'];
31 public static function run()
40 public function checkDeps()
42 foreach ($this->deps as $package => $class) {
43 if (!class_exists($class, true)) {
44 $this->fail('PEAR package not installed: ' . $package);
48 $geshi = stream_resolve_include_path(
49 $GLOBALS['phorkie']['cfg']['geshi']
51 if ($geshi === false) {
52 $this->fail('GeSHi not available');
55 $markdown = stream_resolve_include_path('markdown.php');
56 if ($markdown === false) {
57 $this->fail('Markdown renderer not available');
61 public function checkDirs()
63 foreach ($this->writableDirs as $name => $dir) {
65 $this->fail($name . ' directory does not exist at ' . $dir);
67 if (!is_writable($dir)) {
68 $this->fail($name . ' directory is not writable at ' . $dir);
73 public function checkGit()
75 $line = exec('git --version', $lines, $retval);
77 $this->fail('Running git executable failed.');
79 if (!preg_match('#^git version ([0-9.]+)$#', $line, $matches)) {
80 $this->fail('git version output format unexpected: ' . $line);
82 if (version_compare($matches[1], '1.7.5') < 0) {
84 'git version needs to be at least 1.7.5, got: ' . $matches[1]
89 public function checkDatabase()
91 if ($this->elasticsearch == '') {
95 $es = parse_url($this->elasticsearch);
96 if (!preg_match("#/.+/#", $es['path'], $matches)) {
98 'Improper elasticsearch url. Elasticsearch requires a'
99 . ' search domain to store your data.'
100 . ' (e.g. http://localhost:9200/phorkie/)'
103 $dbs = new Database();
104 $dbs->getSetup()->setup();
107 public function fail($msg)
109 throw new Exception($msg);