This commit is contained in:
2024-07-20 19:23:43 +02:00
parent d608a990b6
commit 3fa2f07ed3
14 changed files with 526 additions and 47 deletions
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
"basePath" => "phpCourse/exam/",
];
+46
View File
@@ -0,0 +1,46 @@
<?php
namespace Config;
class Config
{
private static array $instances = [];
private array $app;
private array $database;
protected function __construct()
{
$this->app = require_once __DIR__ . "/app.php";
$this->database = require_once __DIR__ . "/database.php";
}
protected function __clone()
{
}
public function __wakeup()
{
throw new \Exception("Cannot unserialize a singleton.");
}
private static function getInstance(): Config
{
$cls = static::class;
if (!isset(self::$instances[$cls])) {
self::$instances[$cls] = new static();
}
return self::$instances[$cls];
}
public static function getBasePath()
{
return Config::getInstance()->app["basePath"];
}
public static function getDatabase()
{
return Config::getInstance()->database;
}
}
+9
View File
@@ -0,0 +1,9 @@
<?php
return [
"host" => "usersql.zedat.fu-berlin.de",
"user" => "khofmann-sql",
"passwd" => "xz8c7m7p",
"database" => "khofmann-db1",
"charset" => "utf8",
];