|
1 | 1 | <?php |
2 | | - |
3 | | -/** |
4 | | -* Central phpPgAdmin configuration. As a user you may modify the |
5 | | -* settings here for your particular configuration. |
6 | | -* |
7 | | -* $Id: config.inc.php-dist,v 1.55 2008/02/18 21:10:31 xzilla Exp $ |
8 | | -*/ |
9 | | - |
| 2 | +// Allows to load yaml config. Matching keys will override config defined in this file |
| 3 | +use Symfony\Component\Yaml\Yaml; |
10 | 4 |
|
11 | 5 |
|
12 | 6 |
|
@@ -67,41 +61,48 @@ $conf['display_sizes'] = false; |
67 | 61 |
|
68 | 62 | // An example server. Create as many of these as you wish, |
69 | 63 | // indexed from zero upwards. |
| 64 | +$server_index=0; |
70 | 65 |
|
71 | | -// Display name for the server on the login screen |
72 | | -$conf['servers'][0]['desc'] = 'PostgreSQL'; |
| 66 | +$conf['servers'][$server_index] = [ |
| 67 | + // Display name for the server on the login screen |
| 68 | + 'desc' => 'PostgreSQL', |
73 | 69 |
|
74 | | -// Hostname or IP address for server. Use '' for UNIX domain socket. |
75 | | -// use 'localhost' for TCP/IP connection on this computer |
76 | | -$conf['servers'][0]['host'] = ''; |
| 70 | + // Hostname or IP address for server. Use '' for UNIX domain socket. |
| 71 | + // use 'localhost' for TCP/IP connection on this computer |
| 72 | + 'host' => '', |
77 | 73 |
|
78 | | -// Database port on server (5432 is the PostgreSQL default) |
79 | | -$conf['servers'][0]['port'] = 5432; |
| 74 | + // Database port on server (5432 is the PostgreSQL default) |
| 75 | + 'port' => 5432, |
80 | 76 |
|
81 | | -// Database SSL mode |
82 | | -// Possible options: disable, allow, prefer, require |
83 | | -// To require SSL on older servers use option: legacy |
84 | | -// To ignore the SSL mode, use option: unspecified |
85 | | -$conf['servers'][0]['sslmode'] = 'allow'; |
| 77 | + // Database SSL mode |
| 78 | + // Possible options: disable, allow, prefer, require |
| 79 | + // To require SSL on older servers use option: legacy |
| 80 | + // To ignore the SSL mode, use option: unspecified |
| 81 | + 'sslmode' => 'allow', |
86 | 82 |
|
87 | | -// Change the default database only if you cannot connect to template1. |
88 | | -// For a PostgreSQL 8.1+ server, you can set this to 'postgres'. |
89 | | -$conf['servers'][0]['defaultdb'] = 'template1'; |
| 83 | + // Change the default database only if you cannot connect to template1. |
| 84 | + // For a PostgreSQL 8.1+ server, you can set this to 'postgres'. |
| 85 | + 'defaultdb' => 'template1', |
90 | 86 |
|
91 | | -// Specify the path to the database dump utilities for this server. |
92 | | -// You can set these to '' if no dumper is available. |
93 | | -$conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump'; |
94 | | -$conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall'; |
| 87 | + // Specify the path to the database dump utilities for this server. |
| 88 | + // You can set these to '' if no dumper is available. |
| 89 | + 'pg_dump_path' => '/usr/bin/pg_dump', |
| 90 | + 'pg_dumpall_path' => '/usr/bin/pg_dumpall', |
| 91 | +]; |
95 | 92 |
|
96 | 93 | // Example for a second server (PostgreSQL for Windows) |
97 | | -//$conf['servers'][1]['desc'] = 'Test Server'; |
98 | | -//$conf['servers'][1]['host'] = '127.0.0.1'; |
99 | | -//$conf['servers'][1]['port'] = 5432; |
100 | | -//$conf['servers'][1]['sslmode'] = 'allow'; |
101 | | -//$conf['servers'][1]['defaultdb'] = 'template1'; |
102 | | -//$conf['servers'][1]['pg_dump_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe'; |
103 | | -//$conf['servers'][1]['pg_dumpall_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe'; |
104 | | - |
| 94 | +/* |
| 95 | +$server_index++; |
| 96 | +$conf['servers'][$server_index][ |
| 97 | + 'desc'=> 'Test Server', |
| 98 | + 'host'=> '127.0.0.1', |
| 99 | + 'port'=> 5432, |
| 100 | + 'sslmode'=> 'allow', |
| 101 | + 'defaultdb'=> 'template1', |
| 102 | + 'pg_dump_path'=> 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe', |
| 103 | + 'pg_dumpall_path'=> 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe' |
| 104 | +]; |
| 105 | +*/ |
105 | 106 |
|
106 | 107 | /* Groups definition */ |
107 | 108 | /* Groups allow administrators to logicaly group servers together under |
@@ -211,18 +212,16 @@ $conf['help_base'] = 'http://www.postgresql.org/docs/%s/interactive/'; |
211 | 212 | // Time in seconds. If set to 0, refreshing data using ajax will be disabled (locks and activity pages) |
212 | 213 | $conf['ajax_refresh'] = 3; |
213 | 214 |
|
214 | | -/** Plugins management |
215 | | - * Add plugin names to the following array to activate them |
216 | | - * Example: |
217 | | - * $conf['plugins'] = array( |
218 | | - * 'Example', |
219 | | - * 'Slony' |
220 | | - * ); |
221 | | - */ |
222 | | -$conf['plugins'] = []; |
223 | | - |
224 | | -/***************************************** |
225 | | - * Don't modify anything below this line * |
226 | | - *****************************************/ |
227 | 215 |
|
228 | | -$conf['version'] = 60; |
| 216 | +// If there's a config.yml in the root folder, parse it and merge its contents with $conf array |
| 217 | +// see config.example.yml |
| 218 | +$yamlConfigPath = implode(DIRECTORY_SEPARATOR, [__DIR__, 'config.yml']); |
| 219 | +if (is_readable($yamlConfigPath) && class_exists('Symfony\Component\Yaml\Yaml')) { |
| 220 | + try { |
| 221 | + $yamlConfig = Symfony\Component\Yaml\Yaml::parseFile($yamlConfigPath); |
| 222 | + $conf = array_merge($conf, $yamlConfig); |
| 223 | + } catch (\Exception $e) { |
| 224 | + die($e->getMessage()); |
| 225 | + error_log($e->getTraceAsString()); |
| 226 | + } |
| 227 | +} |
0 commit comments