This commit is contained in:
William 2022-01-21 21:32:21 +01:00
parent 836c5dc183
commit 287b2c2224
2 changed files with 23 additions and 11 deletions

View File

@ -6,16 +6,11 @@ class App
public object $database; public object $database;
public object $session; public object $session;
public function __construct() public function __construct(array $config, Database $database, Session $session)
{ {
// Require configuration file $this->config = $config;
$this->config = require __DIR__ . '/../config.php'; $this->database = $database;
$this->session = $session;
// Connect to database
$this->database = new Database($this->config['database']);
// Instantiate new session
$this->session = new Session;
} }
// Grab model // Grab model

View File

@ -17,5 +17,22 @@ spl_autoload_register(function ($class_name) {
require __DIR__ . '/core/' . $class_name . '.php'; require __DIR__ . '/core/' . $class_name . '.php';
}); });
// God mode class that instantiates many other classes... or something like that // Setup
return new App(); $config = require __DIR__ . '/config.php';
$database = new Database($config['database']);
$session = new Session;
$app = new App(
$config,
$database,
$session
);
// We will want to use $app instead
unset(
$config,
$database,
$session
);
return $app;