Skip to content

Commit f1ccff5

Browse files
committed
adds support for yaml
1 parent f1bae70 commit f1ccff5

File tree

4 files changed

+160
-110
lines changed

4 files changed

+160
-110
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
"slim/twig-view": "~2.5.1",
3636
"twig/twig": "~1.42.4",
3737
"adodb/adodb-php": "^5.20",
38-
"slim/flash": "^0.4.0"
38+
"slim/flash": "^0.4.0",
39+
"symfony/yaml": "^5.0"
3940
},
4041
"require-dev": {
4142
"kint-php/kint": "~3.3",

composer.lock

Lines changed: 60 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.example.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# uncomment to turn debug mode on/off
2+
debugmode: false
3+
# by default, display tables size.
4+
# displaying schema sizes may hit performance
5+
display_sizes:
6+
- tables: true
7+
schemas: false
8+
servers:
9+
# Define a server
10+
- desc: "Server on remote host"
11+
host: server.host1.com
12+
port: 5432
13+
sslmode: prefer
14+
defaultdb: template1
15+
pg_dump_path: /usr/bin/pg_dump
16+
pg_dumpall_path: /usr/bin/pg_dumpall
17+
theme:
18+
default: default
19+
hiddendbs:
20+
- rdsadmin
21+
# Define a second server
22+
- desc: "Server on localhost"
23+
host: localhost
24+
pg_dump_path: /usr/bin/pg_dump
25+
pg_dumpall_path: /usr/bin/pg_dumpall
26+
theme:
27+
default: default
28+
port: 5433
29+
sslmode: prefer
30+
hiddendbs:
31+
- rdsadmin
32+
- postgres
33+
34+
default_lang: auto
35+
autocomplete: "default on"
36+
extra_login_security: true
37+
owned_only: true
38+
show_comments: true
39+
show_advanced: false
40+
show_system: false
41+
min_password_length: 1
42+
left_width: 200
43+
theme: default
44+
show_oids: false
45+
max_rows: 30
46+
max_chars: 50
47+
use_xhtml_strict: false
48+
help_base: "http://www.postgresql.org/docs/%s/interactive/"
49+
ajax_refresh: 3
50+
version: 60

config.inc.php-dist

Lines changed: 48 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<?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;
104

115

126

@@ -67,41 +61,48 @@ $conf['display_sizes'] = false;
6761

6862
// An example server. Create as many of these as you wish,
6963
// indexed from zero upwards.
64+
$server_index=0;
7065

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',
7369

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' => '',
7773

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,
8076

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',
8682

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',
9086

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+
];
9592

9693
// 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+
*/
105106

106107
/* Groups definition */
107108
/* Groups allow administrators to logicaly group servers together under
@@ -211,18 +212,16 @@ $conf['help_base'] = 'http://www.postgresql.org/docs/%s/interactive/';
211212
// Time in seconds. If set to 0, refreshing data using ajax will be disabled (locks and activity pages)
212213
$conf['ajax_refresh'] = 3;
213214

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-
*****************************************/
227215

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

Comments
 (0)