default sqlite support + legacy support
This commit is contained in:
parent
805ef7e2a9
commit
13eeee540f
4 changed files with 32 additions and 17 deletions
|
@ -16,16 +16,16 @@ class Config
|
|||
throw new ConfigException('Cannot read config file.');
|
||||
}
|
||||
|
||||
self::$_settings = parse_ini_file($config_file);
|
||||
if(self::$_settings === false){
|
||||
$default_settings = parse_ini_file($config_file);
|
||||
if($default_settings === false){
|
||||
throw new ConfigException('Cannot parse config file.');
|
||||
}
|
||||
|
||||
$config_file = PROJECT_PATH.self::CUSTOM;
|
||||
if(is_readable($config_file)){
|
||||
$custom_settings = [];
|
||||
if(is_readable($config_file = PROJECT_PATH.self::CUSTOM)){
|
||||
$custom = parse_ini_file($config_file);
|
||||
if($custom !== false){
|
||||
self::$_settings = array_merge(self::$_settings, $custom);
|
||||
$custom_settings = $custom;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -39,10 +39,19 @@ class Config
|
|||
$custom['thumbnails_path'] = 't/';
|
||||
}
|
||||
|
||||
self::$_settings = array_merge(self::$_settings, $custom);
|
||||
$custom_settings = array_merge($custom_settings, $custom);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback for versions, where mysql was default
|
||||
if(!array_key_exists('db_connection', $custom_settings) && array_key_exists('mysql_user', $custom_settings) &&
|
||||
(array_key_exists('mysql_socket', $custom_settings) || array_key_exists('mysql_host', $custom_settings))) {
|
||||
$custom_settings['db_connection'] = 'mysql';
|
||||
}
|
||||
|
||||
// Merge default and custom settings
|
||||
self::$_settings = array_merge($default_settings, $custom_settings);
|
||||
|
||||
// From envs
|
||||
$envs = getenv();
|
||||
$env_prefix_len = strlen(self::ENV_PREFIX);
|
||||
|
|
|
@ -21,7 +21,7 @@ class DB
|
|||
}
|
||||
|
||||
public static function connection() {
|
||||
return Config::get_safe('db_connection', 'mysql');
|
||||
return Config::get_safe('db_connection', 'sqlite');
|
||||
}
|
||||
|
||||
// Initialise PDO object
|
||||
|
|
18
config.ini
18
config.ini
|
@ -1,15 +1,15 @@
|
|||
[database]
|
||||
db_connection = mysql
|
||||
;mysql_socket = /tmp/mariadb55.sock
|
||||
mysql_host = mariadb
|
||||
mysql_port = 3306
|
||||
mysql_user = root
|
||||
mysql_pass = root
|
||||
db_name = blog
|
||||
db_connection = sqlite
|
||||
;sqlite_db = data/sqlite.db
|
||||
|
||||
;[database]
|
||||
;db_connection = sqlite
|
||||
;sqlite_db = data/sqlite.db
|
||||
;db_connection = mysql
|
||||
;mysql_socket = /tmp/mysql.sock
|
||||
;mysql_host = localhost
|
||||
;mysql_port = 3306
|
||||
;mysql_user = root
|
||||
;mysql_pass = root
|
||||
;db_name = blog
|
||||
|
||||
[profile]
|
||||
title = Blog
|
||||
|
|
|
@ -6,6 +6,12 @@ services:
|
|||
container_name: blog_apache
|
||||
environment:
|
||||
TZ: Europe/Vienna
|
||||
BLOG_DB_CONNECTION: mysql
|
||||
BLOG_MYSQL_HOST: mariadb
|
||||
BLOG_MYSQL_PORT: 3306
|
||||
BLOG_MYSQL_USER: root
|
||||
BLOG_MYSQL_PASS: root
|
||||
BLOG_DB_NAME: blog
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- ${HTTP_PORT-80}:80
|
||||
|
@ -22,4 +28,4 @@ services:
|
|||
- mariadb:/var/lib/mysql
|
||||
- ./app/db/mysql:/docker-entrypoint-initdb.d:ro
|
||||
volumes:
|
||||
mariadb:
|
||||
mariadb:
|
||||
|
|
Loading…
Reference in a new issue