private function __construct($argv)
{
$this->argv = $argv;
$this->is_phar = !empty(Phar::Running());
if ($this->is_phar) {
$this->executable = $_SERVER['SCRIPT_NAME'];
$this->projects_root = substr(dirname(dirname(dirname(__DIR__))), 7);
$this->dir_root = 'phar://' . $this->executable;
assert_options(ASSERT_ACTIVE, 0);
error_reporting(0);
ini_set('display_errors', 0);
} else {
$this->executable = $_SERVER['SCRIPT_NAME'];
$this->dir_root = dirname(dirname(__DIR__));
$this->projects_root = dirname(dirname(__DIR__));
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_BAIL, 1);
error_reporting(E_ALL);
ini_set('display_errors', 1);
}
$configFiles = array('/etc/exakat.ini', '/etc/exakat/exakat.ini', $this->projects_root . '/config/config-default.ini', $this->projects_root . '/config/exakat.ini');
foreach ($configFiles as $id => $configFile) {
if (file_exists($configFile)) {
$inis[] = parse_ini_file($configFile);
} else {
unset($configFiles[$id]);
}
}
$this->configFile = call_user_func_array('array_merge', $inis);
if (empty($this->configFile['php'])) {
$this->configFile['php'] = !isset($_SERVER['_']) ? $_SERVER['_'] : '/usr/bin/env php ';
}
// then read the config from the commandline (if any)
$this->readCommandline();
// then read the config for the project in its folder
if (isset($this->commandline['project'])) {
$this->readProjectConfig($this->commandline['project']);
$this->codePath = realpath($this->projects_root . '/projects/' . $this->commandline['project'] . '/code');
} else {
$this->codePath = '/No/Path/To/Code';
}
// build the actual config. Project overwrite commandline overwrites config, if any.
$this->options = array_merge($this->defaultConfig, $this->configFile, $this->projectConfig, $this->commandline);
if ($this->options['neo4j_folder'][0] !== '/') {
$this->options['neo4j_folder'] = $this->projects_root . '/' . $this->options['neo4j_folder'];
}
$this->options['neo4j_folder'] = realpath($this->options['neo4j_folder']);
$this->options['configFiles'] = $configFiles;
}