Add default values and switch to minimum PHP7 version

This commit is contained in:
2021-01-27 12:56:49 +03:00
parent ee66f4dfdc
commit 9250c8d372
2 changed files with 8 additions and 11 deletions

View File

@@ -58,15 +58,12 @@ class HRCCommand extends Command
file_put_contents($result_file, json_encode($result));
}
private function getCoreConfig($name)
private function getCoreConfig($name, $default = null)
{
$config = parse_ini_file(CORE_PATH . '/../../db.ini');
$config = array_change_key_case($config);
$config = array_map(function($value) {
return mb_strtolower($value);
}, $config);
return $config[$name];
return $config[$name] ?? $default;
}
public function initDB()
@@ -74,10 +71,10 @@ class HRCCommand extends Command
$code = $this->option('unn');
DB::disconnect('mysql');
Config::set('database.connections.mysql.username', $this->getCoreConfig('user'));
Config::set('database.connections.mysql.password', $this->getCoreConfig('password'));
Config::set('database.connections.mysql.host', $this->getCoreConfig('server'));
Config::set('database.connections.mysql.port', $this->getCoreConfig('port'));
Config::set('database.connections.mysql.username', $this->getCoreConfig('user', 'hrc'));
Config::set('database.connections.mysql.password', $this->getCoreConfig('password', 'hrc.lan'));
Config::set('database.connections.mysql.host', $this->getCoreConfig('server', '127.0.0.1'));
Config::set('database.connections.mysql.port', $this->getCoreConfig('port', '3306'));
Config::set('database.connections.mysql.database', $code);
DB::reconnect();
}

View File

@@ -9,7 +9,7 @@
"license": "MIT",
"type": "project",
"require": {
"php": "^7.3|^8.0",
"php": "7.0",
"laravel/lumen-framework": "^8.0",
"ext-json": "*"
},