diff options
author | ffflabs <amenadiel@gmail.com> | 2020-02-26 00:08:18 +0300 |
---|---|---|
committer | ffflabs <amenadiel@gmail.com> | 2020-02-26 00:16:35 +0300 |
commit | f1ccff573865cb6e91a75bd6c389659a3c63a156 (patch) | |
tree | dc1a340dfcc2e0951d5bfa5903b90ab02f963506 | |
parent | f1bae70b23dfbc39449cf40161356091642f27ae (diff) |
adds support for yaml
-rw-r--r-- | composer.json | 3 | ||||
-rw-r--r-- | composer.lock | 120 | ||||
-rw-r--r-- | config.example.yml | 50 | ||||
-rw-r--r-- | config.inc.php-dist | 97 |
4 files changed, 160 insertions, 110 deletions
diff --git a/composer.json b/composer.json index e146f6d8..4c569bda 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,8 @@ "slim/twig-view": "~2.5.1", "twig/twig": "~1.42.4", "adodb/adodb-php": "^5.20", - "slim/flash": "^0.4.0" + "slim/flash": "^0.4.0", + "symfony/yaml": "^5.0" }, "require-dev": { "kint-php/kint": "~3.3", diff --git a/composer.lock b/composer.lock index c0d58f0f..b717fdfe 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4d0807c867bfdbd9141195705ca1731d", + "content-hash": "ee6f925218a52a37f1df9dd6c580ee95", "packages": [ { "name": "adodb/adodb-php", @@ -486,6 +486,65 @@ "time": "2020-01-13T11:15:53+00:00" }, { + "name": "symfony/yaml", + "version": "v5.0.4", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a", + "reference": "69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a", + "shasum": "" + }, + "require": { + "php": "^7.2.5", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<4.4" + }, + "require-dev": { + "symfony/console": "^4.4|^5.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2020-01-21T11:12:28+00:00" + }, + { "name": "twig/twig", "version": "v1.42.4", "source": { @@ -3202,65 +3261,6 @@ "time": "2020-01-25T15:56:29+00:00" }, { - "name": "symfony/yaml", - "version": "v5.0.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a", - "reference": "69b44e3b8f90949aee2eb3aa9b86ceeb01cbf62a", - "shasum": "" - }, - "require": { - "php": "^7.2.5", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<4.4" - }, - "require-dev": { - "symfony/console": "^4.4|^5.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2020-01-21T11:12:28+00:00" - }, - { "name": "theseer/tokenizer", "version": "1.1.3", "source": { diff --git a/config.example.yml b/config.example.yml new file mode 100644 index 00000000..14b53843 --- /dev/null +++ b/config.example.yml @@ -0,0 +1,50 @@ +# uncomment to turn debug mode on/off +debugmode: false +# by default, display tables size. +# displaying schema sizes may hit performance +display_sizes: + - tables: true + schemas: false +servers: + # Define a server + - desc: "Server on remote host" + host: server.host1.com + port: 5432 + sslmode: prefer + defaultdb: template1 + pg_dump_path: /usr/bin/pg_dump + pg_dumpall_path: /usr/bin/pg_dumpall + theme: + default: default + hiddendbs: + - rdsadmin + # Define a second server + - desc: "Server on localhost" + host: localhost + pg_dump_path: /usr/bin/pg_dump + pg_dumpall_path: /usr/bin/pg_dumpall + theme: + default: default + port: 5433 + sslmode: prefer + hiddendbs: + - rdsadmin + - postgres + +default_lang: auto +autocomplete: "default on" +extra_login_security: true +owned_only: true +show_comments: true +show_advanced: false +show_system: false +min_password_length: 1 +left_width: 200 +theme: default +show_oids: false +max_rows: 30 +max_chars: 50 +use_xhtml_strict: false +help_base: "http://www.postgresql.org/docs/%s/interactive/" +ajax_refresh: 3 +version: 60 diff --git a/config.inc.php-dist b/config.inc.php-dist index eecb7ac1..c540238d 100644 --- a/config.inc.php-dist +++ b/config.inc.php-dist @@ -1,12 +1,6 @@ <?php - -/** -* Central phpPgAdmin configuration. As a user you may modify the -* settings here for your particular configuration. -* -* $Id: config.inc.php-dist,v 1.55 2008/02/18 21:10:31 xzilla Exp $ -*/ - +// Allows to load yaml config. Matching keys will override config defined in this file +use Symfony\Component\Yaml\Yaml; @@ -67,41 +61,48 @@ $conf['display_sizes'] = false; // An example server. Create as many of these as you wish, // indexed from zero upwards. +$server_index=0; -// Display name for the server on the login screen -$conf['servers'][0]['desc'] = 'PostgreSQL'; +$conf['servers'][$server_index] = [ + // Display name for the server on the login screen + 'desc' => 'PostgreSQL', -// Hostname or IP address for server. Use '' for UNIX domain socket. -// use 'localhost' for TCP/IP connection on this computer -$conf['servers'][0]['host'] = ''; + // Hostname or IP address for server. Use '' for UNIX domain socket. + // use 'localhost' for TCP/IP connection on this computer + 'host' => '', -// Database port on server (5432 is the PostgreSQL default) -$conf['servers'][0]['port'] = 5432; + // Database port on server (5432 is the PostgreSQL default) + 'port' => 5432, -// Database SSL mode -// Possible options: disable, allow, prefer, require -// To require SSL on older servers use option: legacy -// To ignore the SSL mode, use option: unspecified -$conf['servers'][0]['sslmode'] = 'allow'; + // Database SSL mode + // Possible options: disable, allow, prefer, require + // To require SSL on older servers use option: legacy + // To ignore the SSL mode, use option: unspecified + 'sslmode' => 'allow', -// Change the default database only if you cannot connect to template1. -// For a PostgreSQL 8.1+ server, you can set this to 'postgres'. -$conf['servers'][0]['defaultdb'] = 'template1'; + // Change the default database only if you cannot connect to template1. + // For a PostgreSQL 8.1+ server, you can set this to 'postgres'. + 'defaultdb' => 'template1', -// Specify the path to the database dump utilities for this server. -// You can set these to '' if no dumper is available. -$conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump'; -$conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall'; + // 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', +]; // Example for a second server (PostgreSQL for Windows) -//$conf['servers'][1]['desc'] = 'Test Server'; -//$conf['servers'][1]['host'] = '127.0.0.1'; -//$conf['servers'][1]['port'] = 5432; -//$conf['servers'][1]['sslmode'] = 'allow'; -//$conf['servers'][1]['defaultdb'] = 'template1'; -//$conf['servers'][1]['pg_dump_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe'; -//$conf['servers'][1]['pg_dumpall_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe'; - +/* +$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 @@ -211,18 +212,16 @@ $conf['help_base'] = 'http://www.postgresql.org/docs/%s/interactive/'; // Time in seconds. If set to 0, refreshing data using ajax will be disabled (locks and activity pages) $conf['ajax_refresh'] = 3; -/** Plugins management - * Add plugin names to the following array to activate them - * Example: - * $conf['plugins'] = array( - * 'Example', - * 'Slony' - * ); - */ -$conf['plugins'] = []; - -/***************************************** - * Don't modify anything below this line * - *****************************************/ -$conf['version'] = 60; +// 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')) { + try { + $yamlConfig = Symfony\Component\Yaml\Yaml::parseFile($yamlConfigPath); + $conf = array_merge($conf, $yamlConfig); + } catch (\Exception $e) { + die($e->getMessage()); + error_log($e->getTraceAsString()); + } +} |