Add default values and switch to minimum PHP7 version
This commit is contained in:
@@ -58,15 +58,12 @@ class HRCCommand extends Command
|
|||||||
file_put_contents($result_file, json_encode($result));
|
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 = parse_ini_file(CORE_PATH . '/../../db.ini');
|
||||||
|
$config = array_change_key_case($config);
|
||||||
|
|
||||||
$config = array_map(function($value) {
|
return $config[$name] ?? $default;
|
||||||
return mb_strtolower($value);
|
|
||||||
}, $config);
|
|
||||||
|
|
||||||
return $config[$name];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function initDB()
|
public function initDB()
|
||||||
@@ -74,10 +71,10 @@ class HRCCommand extends Command
|
|||||||
$code = $this->option('unn');
|
$code = $this->option('unn');
|
||||||
|
|
||||||
DB::disconnect('mysql');
|
DB::disconnect('mysql');
|
||||||
Config::set('database.connections.mysql.username', $this->getCoreConfig('user'));
|
Config::set('database.connections.mysql.username', $this->getCoreConfig('user', 'hrc'));
|
||||||
Config::set('database.connections.mysql.password', $this->getCoreConfig('password'));
|
Config::set('database.connections.mysql.password', $this->getCoreConfig('password', 'hrc.lan'));
|
||||||
Config::set('database.connections.mysql.host', $this->getCoreConfig('server'));
|
Config::set('database.connections.mysql.host', $this->getCoreConfig('server', '127.0.0.1'));
|
||||||
Config::set('database.connections.mysql.port', $this->getCoreConfig('port'));
|
Config::set('database.connections.mysql.port', $this->getCoreConfig('port', '3306'));
|
||||||
Config::set('database.connections.mysql.database', $code);
|
Config::set('database.connections.mysql.database', $code);
|
||||||
DB::reconnect();
|
DB::reconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"type": "project",
|
"type": "project",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.3|^8.0",
|
"php": "7.0",
|
||||||
"laravel/lumen-framework": "^8.0",
|
"laravel/lumen-framework": "^8.0",
|
||||||
"ext-json": "*"
|
"ext-json": "*"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user