summaryrefslogtreecommitdiff
path: root/includes/engelsystem.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2017-11-01 12:35:45 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-11-01 12:35:45 +0100
commite727b367cc77452b58bc2d9360bcde97b7572288 (patch)
treeb5dc6720cd4a8a73f960669c9b3a068b8f731a24 /includes/engelsystem.php
parente55d5c7c15411eb58dd99113d94ee8ba55fd414a (diff)
Moved includes to own file
Diffstat (limited to 'includes/engelsystem.php')
-rw-r--r--includes/engelsystem.php77
1 files changed, 77 insertions, 0 deletions
diff --git a/includes/engelsystem.php b/includes/engelsystem.php
new file mode 100644
index 00000000..f9535847
--- /dev/null
+++ b/includes/engelsystem.php
@@ -0,0 +1,77 @@
+<?php
+
+use Engelsystem\Application;
+use Engelsystem\Config\Config;
+use Engelsystem\Exceptions\Handler as ExceptionHandler;
+use Engelsystem\Http\Request;
+use Symfony\Component\HttpFoundation\Session\Session;
+use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
+use Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage;
+
+/**
+ * This file includes all needed functions, connects to the db etc.
+ */
+require_once __DIR__ . '/autoload.php';
+
+
+/**
+ * Initialize and bootstrap the application
+ */
+$app = new Application(realpath(__DIR__ . DIRECTORY_SEPARATOR . '..'));
+$appConfig = $app->make(Config::class);
+$appConfig->set(require config_path('app.php'));
+$app->bootstrap($appConfig);
+
+
+/**
+ * Configure application
+ */
+date_default_timezone_set($app->get('config')->get('timezone'));
+
+if (config('environment') == 'development') {
+ $errorHandler = $app->get('error.handler');
+ $errorHandler->setEnvironment(ExceptionHandler::ENV_DEVELOPMENT);
+ ini_set('display_errors', true);
+ error_reporting(E_ALL);
+} else {
+ ini_set('display_errors', false);
+}
+
+
+/**
+ * Check for maintenance
+ */
+if ($app->get('config')->get('maintenance')) {
+ echo file_get_contents(__DIR__ . '/../templates/maintenance.html');
+ die();
+}
+
+
+/**
+ * Initialize Request
+ *
+ * @var Request $request
+ */
+$request = Request::createFromGlobals();
+$app->instance('request', $request);
+
+
+/**
+ * Include legacy code
+ */
+require __DIR__ . '/includes.php';
+
+
+/**
+ * Init application
+ */
+$sessionStorage = (PHP_SAPI != 'cli' ? new NativeSessionStorage(['cookie_httponly' => true]) : new MockArraySessionStorage());
+$session = new Session($sessionStorage);
+$app->instance('session', $session);
+$session->start();
+$request->setSession($session);
+
+
+gettext_init();
+
+load_auth();