Skip to content

Commit 3a069a8

Browse files
committed
bugsfixes on config files
1 parent 4552479 commit 3a069a8

File tree

8 files changed

+163
-184
lines changed

8 files changed

+163
-184
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Other enhancements are in progress and would be a nice to have:
3232

3333
(If you're using PHP 5.6+, you can still try versions RC2 and below, but you should really, realy upgrade).
3434

35+
---
36+
3537
## Installation
3638

3739
### Using Composer (recommended)
@@ -41,7 +43,7 @@ Other enhancements are in progress and would be a nice to have:
4143
Install with composer running the following command in your shell (replacing <FOLDER> whith your desired folder name)
4244

4345
```sh
44-
composer create-project huasofoundries/phppgadmin6 <FOLDER> v6.0.*@rc --no-dev --prefer-dist
46+
composer create-project huasofoundries/phppgadmin6 <FOLDER> v6.0.* --no-dev --prefer-dist
4547
```
4648

4749
Alternatively, clone this repo and run (inside then folder where the project was cloned)
@@ -56,6 +58,12 @@ You can set the config options either in a `config.inc.php` (refer to [config.in
5658
AND/OR a [config.yml](config.yml). The use of the latter is complely optional. Keep in mind the config entries are merged giving
5759
precedence to the ones in the YAML file.
5860

61+
### Server Blocks
62+
63+
Configuration has a `servers` entry whose details are in their on Wiki section: "[Config: Servers](https://github.com/HuasoFoundries/phpPgAdmin6/wiki/Config:-servers)"
64+
65+
---
66+
5967
## Rewrite Rules
6068

6169
As this project is built over [Slim Framework 3](https://www.slimframework.com/), **you'll need some rewrite rules for nice-urls to work**.
@@ -67,35 +75,28 @@ Please refer to Slim Framework 3 instructions on rewrite rules config for:
6775
- [Lighttpd](http://www.slimframework.com/docs/v3/start/web-servers.html#lighttpd)
6876
- [IIS](http://www.slimframework.com/docs/v3/start/web-servers.html#iis)
6977
- [HHVM](http://www.slimframework.com/docs/v3/start/web-servers.html#hiphop-virtual-machine)
70-
- [PHP Built-in dev server]http://www.slimframework.com/docs/v3/start/web-servers.html#php-built-in-server
78+
- [PHP Built-in dev server](http://www.slimframework.com/docs/v3/start/web-servers.html#php-built-in-server)
7179

7280
## Running inside a subfolder
7381

7482
If you're planning to run phpPgAdmin6 under a subfolder, make sure you set it **explicitly** in the config file(s). I gave up trying to
7583
figure out the subfolder automatically and it's outside of this project's scope.
7684

77-
This is:
78-
79-
- In `config.inc.php`
85+
To set it in `config.inc.php`
8086

8187
```
82-
$conf['subfolder']='/phppga_subfolder';
83-
```
84-
85-
OR
86-
87-
- In `config.yml`
88-
89-
````
9088
$conf = [
9189
'subfolder' => '/phppga_subfolder',
9290
'other config...' => 'sure'
9391
];
92+
```
93+
94+
To set it in `config.yml`
9495

9596
```yaml
9697
default_lang: auto
9798
subfolder: '/phppha_subfolder'
98-
````
99+
```
99100
100101
Remember that values set on the `yml` config take precedence.
101102

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"vimeo/psalm": "^3.9"
3939
},
4040
"extra": {
41-
"version": "6.0.1"
41+
"version": "6.0.0"
4242
},
4343
"autoload": {
4444
"psr-4": {

config.example.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# uncomment to turn debug mode on/off
1+
# turns debug mode on/off
22
debugmode: false
33
# by default, display tables size.
44
# displaying schema sizes may hit performance
@@ -7,7 +7,7 @@ display_sizes:
77
schemas: false
88
servers:
99
# Define a server
10-
- desc: "Server on remote host"
10+
- desc: 'Server on remote host'
1111
host: server.host1.com
1212
port: 5432
1313
sslmode: prefer
@@ -19,7 +19,7 @@ servers:
1919
hiddendbs:
2020
- rdsadmin
2121
# Define a second server
22-
- desc: "Server on localhost"
22+
- desc: 'Server on localhost'
2323
host: localhost
2424
pg_dump_path: /usr/bin/pg_dump
2525
pg_dumpall_path: /usr/bin/pg_dumpall
@@ -32,7 +32,7 @@ servers:
3232
- postgres
3333

3434
default_lang: auto
35-
autocomplete: "default on"
35+
autocomplete: 'default on'
3636
extra_login_security: true
3737
owned_only: true
3838
show_comments: true
@@ -45,6 +45,6 @@ show_oids: false
4545
max_rows: 30
4646
max_chars: 50
4747
use_xhtml_strict: false
48-
help_base: "http://www.postgresql.org/docs/%s/interactive/"
48+
help_base: 'http://www.postgresql.org/docs/%s/interactive/'
4949
ajax_refresh: 3
50-
version: 60
50+
version: 61

config.inc.php-dist

Lines changed: 33 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ $conf = [
2727
*/
2828
'debugmode' => false,
2929

30+
/**
31+
* Don't touch this value. It's used to inform the config structure has a breaking change
32+
*
33+
*/
34+
'version'=> 61
35+
3036
];
3137

3238
$conf['register_debuggers'] = function () {
@@ -78,6 +84,11 @@ $conf['register_debuggers'] = function () {
7884
// indexed from zero upwards.
7985
$server_index = 0;
8086

87+
/**
88+
* $conf['servers'] is an array that holds (at least) one server block.
89+
* @see https://github.com/HuasoFoundries/phpPgAdmin6/wiki/Config:-servers
90+
*
91+
*/
8192
$conf['servers'][$server_index] = [
8293
// Display name for the server on the login screen
8394
'desc' => 'PostgreSQL',
@@ -102,61 +113,9 @@ $conf['servers'][$server_index] = [
102113
// Specify the path to the database dump utilities for this server.
103114
// You can set these to '' if no dumper is available.
104115
'pg_dump_path' => '/usr/bin/pg_dump',
105-
'pg_dumpall_path' => '/usr/bin/pg_dumpall',
116+
'pg_dumpall_path' => '/usr/bin/pg_dumpall'
106117
];
107118

108-
// Example for a second server (PostgreSQL for Windows)
109-
/*
110-
$server_index++;
111-
$conf['servers'][$server_index][
112-
'desc'=> 'Test Server',
113-
'host'=> '127.0.0.1',
114-
'port'=> 5432,
115-
'sslmode'=> 'allow',
116-
'defaultdb'=> 'template1',
117-
'pg_dump_path'=> 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe',
118-
'pg_dumpall_path'=> 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe'
119-
];
120-
*/
121-
122-
/* Groups definition */
123-
/* Groups allow administrators to logicaly group servers together under
124-
* group nodes in the left browser tree
125-
*
126-
* The group '0' description
127-
*/
128-
//$conf['srv_groups'][0]['desc'] = 'group one';
129-
130-
/* Add here servers indexes belonging to the group '0' seperated by comma */
131-
//$conf['srv_groups'][0]['servers'] = '0,1,2';
132-
133-
/* A server can belong to multi groups. Here server 1 is referenced in both
134-
* 'group one' and 'group two'*/
135-
//$conf['srv_groups'][1]['desc'] = 'group two';
136-
//$conf['srv_groups'][1]['servers'] = '3,1';
137-
138-
/* A group can be nested in one or more existing groups using the 'parents'
139-
* parameter. Here the group 'group three' contains only one server and will
140-
* appear as a subgroup in both 'group one' and 'group two':
141-
*/
142-
//$conf['srv_groups'][2]['desc'] = 'group three';
143-
//$conf['srv_groups'][2]['servers'] = '4';
144-
//$conf['srv_groups'][2]['parents'] = '0,1';
145-
146-
/* Warning: Only groups with no parents appears at the root of the tree. */
147-
148-
/* You can apply specific theme depending on servers, users and databases
149-
* The priority order is :
150-
* * the theme defined for a server
151-
* * the theme defined for a database apply over the server one
152-
* * the theme defined for a user apply over the database one
153-
*/
154-
/* Example for servers */
155-
//$conf['servers'][0]['theme']['default'] = 'default';
156-
/* Example for users */
157-
//$conf['servers'][0]['theme']['user']['specific_user'] = 'default';
158-
/* Example for databases */
159-
//$conf['servers'][0]['theme']['db']['specific_db'] = 'default';
160119

161120
// Default language. E.g.: 'english', 'polish', etc. See lang/ directory
162121
// for all possibilities. If you specify 'auto' (the default) it will use
@@ -230,12 +189,29 @@ $conf['ajax_refresh'] = 3;
230189
// If there's a config.yml in the root folder, parse it and merge its contents with $conf array
231190
// see config.example.yml
232191
$yamlConfigPath = implode(DIRECTORY_SEPARATOR, [__DIR__, 'config.yml']);
233-
if (is_readable($yamlConfigPath) && class_exists('Symfony\Component\Yaml\Yaml')) {
192+
if (\is_readable($yamlConfigPath) && \class_exists('Symfony\Component\Yaml\Yaml')) {
234193
try {
235194
$yamlConfig = Symfony\Component\Yaml\Yaml::parseFile($yamlConfigPath);
236-
$conf = array_merge($conf, $yamlConfig);
195+
// Servers and srv_groups must be merged beforehand
196+
$servers = $conf['servers'] ?? [];
197+
foreach ($yamlConfig['servers'] ?? [] as $index => $srv) {
198+
$servers[] = $srv;
199+
}
200+
$srv_groups = $conf['srv_groups'] ?? [];
201+
foreach ($yamlConfig['srv_groups'] ?? [] as $index => $srv_group) {
202+
$srv_groups[] = $srv;
203+
}
204+
205+
$yamlConfig['srv_groups'] = array_merge([
206+
$conf['srv_groups'] ?? [],
207+
$yamlConfig['srv_groups'] ?? [],
208+
]);
209+
$conf = \array_merge($conf, $yamlConfig);
210+
211+
$conf['servers'] = $servers ?? [];
212+
$conf['srv_groups'] = $srv_groups ?? [];
237213
} catch (\Exception $e) {
238214
die($e->getMessage());
239-
error_log($e->getTraceAsString());
215+
\error_log($e->getTraceAsString());
240216
}
241-
}
217+
}

0 commit comments

Comments
 (0)