API refactor + CLI docker

This commit is contained in:
2022-02-21 13:01:03 +01:00
parent 8a7e25837f
commit 28c9222b98
22 changed files with 111 additions and 335 deletions

14
cli.php
View File

@@ -39,8 +39,20 @@ function getDatabaseConfig(): ConnectionData {
return new $configClass();
}
$config = new Configuration();
$database = $config->getDatabase();
if ($database !== null && $database->getProperty("isDocker", false) && !is_file("/.dockerenv")) {
$command = array_merge(["docker", "exec", "-it", "php", "php"], /*array_map(function ($arg) { return escapeshellarg($arg); }, */$argv);
var_dump(implode(" ", $command));
$proc = proc_open($command, [1 => STDOUT, 2 => STDERR], $pipes, "/application");
sleep(1);
/*var_dump(stream_get_contents($pipes[1]));
var_dump(stream_get_contents($pipes[2]));*/
exit(proc_close($proc));
}
function getUser(): ?User {
$config = new Configuration();
global $config;
$user = new User($config);
if (!$user->getSQL() || !$user->getSQL()->isConnected()) {
printLine("Could not establish database connection");