Commit
This commit is contained in:
parent
836c5dc183
commit
287b2c2224
@ -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
|
||||
|
21
app/inc.php
21
app/inc.php
@ -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;
|
Reference in New Issue
Block a user