Provide missing "AlmanacInterfaceTransactionQuery"
[phabricator.git] / conf / __init_conf__.php
blob18c132c6d42bf4bdea74f823573f663d86f33111
1 <?php
3 function phabricator_read_config_file($original_config) {
4 $root = dirname(dirname(__FILE__));
6 // Accept either "myconfig" (preferred) or "myconfig.conf.php".
7 $config = preg_replace('/\.conf\.php$/', '', $original_config);
8 $full_config_path = $root.'/conf/'.$config.'.conf.php';
10 if (!Filesystem::pathExists($full_config_path)) {
11 // These are very old configuration files which we used to ship with
12 // by default. File based configuration was de-emphasized once web-based
13 // configuration was built. The actual files were removed to reduce
14 // user confusion over how to configure Phabricator.
16 switch ($config) {
17 case 'default':
18 case 'production':
19 return array();
20 case 'development':
21 return array(
22 'phabricator.developer-mode' => true,
23 'darkconsole.enabled' => true,
27 $files = id(new FileFinder($root.'/conf/'))
28 ->withType('f')
29 ->withSuffix('conf.php')
30 ->withFollowSymlinks(true)
31 ->find();
33 foreach ($files as $key => $file) {
34 $file = trim($file, './');
35 $files[$key] = preg_replace('/\.conf\.php$/', '', $file);
37 $files = ' '.implode("\n ", $files);
39 throw new Exception(
40 pht(
41 "CONFIGURATION ERROR\n".
42 "Config file '%s' does not exist. Valid config files are:\n\n%s",
43 $original_config,
44 $files));
47 // Make sure config file errors are reported.
48 $old_error_level = error_reporting(E_ALL | E_STRICT);
49 $old_display_errors = ini_get('display_errors');
50 ini_set('display_errors', 1);
52 ob_start();
53 $conf = include $full_config_path;
54 $errors = ob_get_clean();
56 error_reporting($old_error_level);
57 ini_set('display_errors', $old_display_errors);
59 if ($conf === false) {
60 throw new Exception(
61 pht(
62 "Failed to read config file '%s': %s",
63 $config,
64 $errors));
67 return $conf;