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 $session;
public function __construct()
public function __construct(array $config, Database $database, Session $session)
{
// Require configuration file
$this->config = require __DIR__ . '/../config.php';
// Connect to database
$this->database = new Database($this->config['database']);
// Instantiate new session
$this->session = new Session;
$this->config = $config;
$this->database = $database;
$this->session = $session;
}
// Grab model

View File

@ -17,5 +17,22 @@ spl_autoload_register(function ($class_name) {
require __DIR__ . '/core/' . $class_name . '.php';
});
// God mode class that instantiates many other classes... or something like that
return new App();
// Setup
$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;