finalize config:: migration; make config.php optional
This commit is contained in:
parent
6b7af973b2
commit
445ac1213c
|
@ -2,7 +2,9 @@
|
|||
class Config {
|
||||
private const _ENVVAR_PREFIX = "TTRSS_";
|
||||
|
||||
/* overriding defaults (defined below in _DEFAULTS[]) via environment: DB_TYPE becomes TTRSS_DB_TYPE, etc */
|
||||
// TODO: this should be extensible so plugins could add their own global directives (with defaults)
|
||||
|
||||
// overriding defaults (defined below in _DEFAULTS[]) via environment: DB_TYPE becomes TTRSS_DB_TYPE, etc
|
||||
|
||||
const DB_TYPE = "DB_TYPE";
|
||||
const DB_HOST = "DB_HOST";
|
||||
|
|
|
@ -17,8 +17,8 @@ class Db
|
|||
// normal usage is Db::pdo()->prepare(...) etc
|
||||
public function pdo_connect() {
|
||||
|
||||
$db_port = defined('DB_PORT') && DB_PORT ? ';port=' . DB_PORT : '';
|
||||
$db_host = defined('DB_HOST') && DB_HOST ? ';host=' . DB_HOST : '';
|
||||
$db_port = Config::get(Config::DB_PORT) ? ';port=' . Config::get(Config::DB_PORT) : '';
|
||||
$db_host = Config::get(Config::DB_HOST) ? ';host=' . Config::get(Config::DB_HOST) : '';
|
||||
|
||||
try {
|
||||
$pdo = new PDO(Config::get(Config::DB_TYPE) . ':dbname=' . Config::get(Config::DB_NAME) . $db_host . $db_port,
|
||||
|
|
|
@ -30,7 +30,10 @@
|
|||
ini_set('display_errors', "false");
|
||||
ini_set('display_startup_errors', "false");
|
||||
|
||||
require_once "config.php";
|
||||
// config.php is optional
|
||||
if (stream_resolve_include_path("config.php"))
|
||||
require_once "config.php";
|
||||
|
||||
require_once "autoload.php";
|
||||
|
||||
if (Config::get(Config::DB_TYPE) == "pgsql") {
|
||||
|
|
Loading…
Reference in New Issue