Skip to content

Commit

Permalink
bugsfixes on config files
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflabs committed May 25, 2020
1 parent 4552479 commit 3a069a8
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 184 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ Other enhancements are in progress and would be a nice to have:

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

---

## Installation

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

```sh
composer create-project huasofoundries/phppgadmin6 <FOLDER> v6.0.*@rc --no-dev --prefer-dist
composer create-project huasofoundries/phppgadmin6 <FOLDER> v6.0.* --no-dev --prefer-dist
```

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

### Server Blocks

Configuration has a `servers` entry whose details are in their on Wiki section: "[Config: Servers](https://github.com/HuasoFoundries/phpPgAdmin6/wiki/Config:-servers)"

---

## Rewrite Rules

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

## Running inside a subfolder

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
figure out the subfolder automatically and it's outside of this project's scope.

This is:

- In `config.inc.php`
To set it in `config.inc.php`

```
$conf['subfolder']='/phppga_subfolder';
```

OR

- In `config.yml`

````
$conf = [
'subfolder' => '/phppga_subfolder',
'other config...' => 'sure'
];
```

To set it in `config.yml`

```yaml
default_lang: auto
subfolder: '/phppha_subfolder'
````
```
Remember that values set on the `yml` config take precedence.

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"vimeo/psalm": "^3.9"
},
"extra": {
"version": "6.0.1"
"version": "6.0.0"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 6 additions & 6 deletions config.example.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# uncomment to turn debug mode on/off
# turns debug mode on/off
debugmode: false
# by default, display tables size.
# displaying schema sizes may hit performance
Expand All @@ -7,7 +7,7 @@ display_sizes:
schemas: false
servers:
# Define a server
- desc: "Server on remote host"
- desc: 'Server on remote host'
host: server.host1.com
port: 5432
sslmode: prefer
Expand All @@ -19,7 +19,7 @@ servers:
hiddendbs:
- rdsadmin
# Define a second server
- desc: "Server on localhost"
- desc: 'Server on localhost'
host: localhost
pg_dump_path: /usr/bin/pg_dump
pg_dumpall_path: /usr/bin/pg_dumpall
Expand All @@ -32,7 +32,7 @@ servers:
- postgres

default_lang: auto
autocomplete: "default on"
autocomplete: 'default on'
extra_login_security: true
owned_only: true
show_comments: true
Expand All @@ -45,6 +45,6 @@ show_oids: false
max_rows: 30
max_chars: 50
use_xhtml_strict: false
help_base: "http://www.postgresql.org/docs/%s/interactive/"
help_base: 'http://www.postgresql.org/docs/%s/interactive/'
ajax_refresh: 3
version: 60
version: 61
90 changes: 33 additions & 57 deletions config.inc.php-dist
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ $conf = [
*/
'debugmode' => false,

/**
* Don't touch this value. It's used to inform the config structure has a breaking change
*
*/
'version'=> 61

];

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

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

// Example for a second server (PostgreSQL for Windows)
/*
$server_index++;
$conf['servers'][$server_index][
'desc'=> 'Test Server',
'host'=> '127.0.0.1',
'port'=> 5432,
'sslmode'=> 'allow',
'defaultdb'=> 'template1',
'pg_dump_path'=> 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe',
'pg_dumpall_path'=> 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe'
];
*/

/* Groups definition */
/* Groups allow administrators to logicaly group servers together under
* group nodes in the left browser tree
*
* The group '0' description
*/
//$conf['srv_groups'][0]['desc'] = 'group one';

/* Add here servers indexes belonging to the group '0' seperated by comma */
//$conf['srv_groups'][0]['servers'] = '0,1,2';

/* A server can belong to multi groups. Here server 1 is referenced in both
* 'group one' and 'group two'*/
//$conf['srv_groups'][1]['desc'] = 'group two';
//$conf['srv_groups'][1]['servers'] = '3,1';

/* A group can be nested in one or more existing groups using the 'parents'
* parameter. Here the group 'group three' contains only one server and will
* appear as a subgroup in both 'group one' and 'group two':
*/
//$conf['srv_groups'][2]['desc'] = 'group three';
//$conf['srv_groups'][2]['servers'] = '4';
//$conf['srv_groups'][2]['parents'] = '0,1';

/* Warning: Only groups with no parents appears at the root of the tree. */

/* You can apply specific theme depending on servers, users and databases
* The priority order is :
* * the theme defined for a server
* * the theme defined for a database apply over the server one
* * the theme defined for a user apply over the database one
*/
/* Example for servers */
//$conf['servers'][0]['theme']['default'] = 'default';
/* Example for users */
//$conf['servers'][0]['theme']['user']['specific_user'] = 'default';
/* Example for databases */
//$conf['servers'][0]['theme']['db']['specific_db'] = 'default';

// Default language. E.g.: 'english', 'polish', etc. See lang/ directory
// for all possibilities. If you specify 'auto' (the default) it will use
Expand Down Expand Up @@ -230,12 +189,29 @@ $conf['ajax_refresh'] = 3;
// If there's a config.yml in the root folder, parse it and merge its contents with $conf array
// see config.example.yml
$yamlConfigPath = implode(DIRECTORY_SEPARATOR, [__DIR__, 'config.yml']);
if (is_readable($yamlConfigPath) && class_exists('Symfony\Component\Yaml\Yaml')) {
if (\is_readable($yamlConfigPath) && \class_exists('Symfony\Component\Yaml\Yaml')) {
try {
$yamlConfig = Symfony\Component\Yaml\Yaml::parseFile($yamlConfigPath);
$conf = array_merge($conf, $yamlConfig);
// Servers and srv_groups must be merged beforehand
$servers = $conf['servers'] ?? [];
foreach ($yamlConfig['servers'] ?? [] as $index => $srv) {
$servers[] = $srv;
}
$srv_groups = $conf['srv_groups'] ?? [];
foreach ($yamlConfig['srv_groups'] ?? [] as $index => $srv_group) {
$srv_groups[] = $srv;
}

$yamlConfig['srv_groups'] = array_merge([
$conf['srv_groups'] ?? [],
$yamlConfig['srv_groups'] ?? [],
]);
$conf = \array_merge($conf, $yamlConfig);

$conf['servers'] = $servers ?? [];
$conf['srv_groups'] = $srv_groups ?? [];
} catch (\Exception $e) {
die($e->getMessage());
error_log($e->getTraceAsString());
\error_log($e->getTraceAsString());
}
}
}
Loading

0 comments on commit 3a069a8

Please sign in to comment.