Simple Route
This commit is contained in:
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
class Config
|
||||
{
|
||||
private static array $instances = [];
|
||||
|
||||
private array $app;
|
||||
private array $database;
|
||||
|
||||
protected function __construct()
|
||||
{
|
||||
$this->app = require_once __DIR__ . "/../../config/app.php";
|
||||
$this->database = require_once __DIR__ . "/../../config/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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user