summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/autoload.php2
-rw-r--r--includes/engelsystem_provider.php95
2 files changed, 16 insertions, 81 deletions
diff --git a/includes/autoload.php b/includes/autoload.php
index f51f89e4..0cd9d355 100644
--- a/includes/autoload.php
+++ b/includes/autoload.php
@@ -6,4 +6,4 @@ if (!is_readable(__DIR__ . '/../vendor/autoload.php')) {
}
// Include composer autoloader
-require_once __DIR__ . '/../vendor/autoload.php';
+$loader = require __DIR__ . '/../vendor/autoload.php';
diff --git a/includes/engelsystem_provider.php b/includes/engelsystem_provider.php
index 3067ab62..48206cb6 100644
--- a/includes/engelsystem_provider.php
+++ b/includes/engelsystem_provider.php
@@ -2,14 +2,8 @@
use Engelsystem\Application;
use Engelsystem\Config\Config;
-use Engelsystem\Database\Db;
use Engelsystem\Exceptions\Handler as ExceptionHandler;
use Engelsystem\Http\Request;
-use Engelsystem\Logger\EngelsystemLogger;
-use Engelsystem\Renderer\HtmlEngine;
-use Engelsystem\Renderer\Renderer;
-use Engelsystem\Routing\UrlGenerator;
-use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
@@ -21,78 +15,21 @@ require_once __DIR__ . '/autoload.php';
/**
- * Initialize the application
+ * Initialize and bootstrap the application
*/
$app = new Application(realpath(__DIR__ . DIRECTORY_SEPARATOR . '..'));
-
-
-/**
- * Bootstrap application
- */
$appConfig = $app->make(Config::class);
-$appConfig->set(app('path.config') . '/app.php');
+$appConfig->set(require config_path('app.php'));
$app->bootstrap($appConfig);
-/**
- * Load configuration
- */
-$config = new Config();
-$app->instance('config', $config);
-$config->set(require __DIR__ . '/../config/config.default.php');
-
-if (file_exists(__DIR__ . '/../config/config.php')) {
- $config->set(array_replace_recursive(
- $config->get(null),
- require __DIR__ . '/../config/config.php'
- ));
-}
-
/**
* Configure application
*/
-date_default_timezone_set($config->get('timezone'));
-
-
-/**
- * Initialize Request
- *
- * @var Request $request
- */
-$request = Request::createFromGlobals();
-$app->instance('request', $request);
-
-
-/**
- * Check for maintenance
- */
-if ($app->get('config')->get('maintenance')) {
- echo file_get_contents(__DIR__ . '/../templates/maintenance.html');
- die();
-}
-
-
-/**
- * Register UrlGenerator
- */
-$urlGenerator = new UrlGenerator();
-$app->instance('routing.urlGenerator', $urlGenerator);
+date_default_timezone_set($app->get('config')->get('timezone'));
-
-/**
- * Initialize renderer
- */
-$renderer = new Renderer();
-$app->instance('renderer', $renderer);
-$renderer->addRenderer(new HtmlEngine());
-
-
-/**
- * Register error handler
- */
-$errorHandler = new ExceptionHandler();
-$app->instance('error.handler', $errorHandler);
if (config('environment') == 'development') {
+ $errorHandler = $app->get('error.handler');
$errorHandler->setEnvironment(ExceptionHandler::ENV_DEVELOPMENT);
ini_set('display_errors', true);
error_reporting(E_ALL);
@@ -102,23 +39,21 @@ if (config('environment') == 'development') {
/**
- * Connect to database
+ * Check for maintenance
*/
-Db::connect(
- 'mysql:host=' . config('database')['host'] . ';dbname=' . config('database')['db'] . ';charset=utf8',
- config('database')['user'],
- config('database')['pw']
-) || die('Error: Unable to connect to database');
-Db::getPdo()->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
-Db::getPdo()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
+if ($app->get('config')->get('maintenance')) {
+ echo file_get_contents(__DIR__ . '/../templates/maintenance.html');
+ die();
+}
+
/**
- * Init logger
+ * Initialize Request
+ *
+ * @var Request $request
*/
-$logger = new EngelsystemLogger();
-$app->instance('logger', $logger);
-$app->bind(LoggerInterface::class, 'logger');
-$app->bind(EngelsystemLogger::class, 'logger');
+$request = Request::createFromGlobals();
+$app->instance('request', $request);
/**