-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
35 lines (27 loc) · 862 Bytes
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
declare(strict_types=1);
use App\ConfigFactory;
use App\Controller;
use App\PostFactory;
use App\Router;
use Pagerange\Markdown\MetaParsedown;
use Symfony\Component\Yaml\Yaml;
use Twig\Environment;
use Twig\Loader\FilesystemLoader;
require __DIR__ . '/vendor/autoload.php';
try {
// Building Dependencies
$parser = new MetaParsedown();
$factory = new PostFactory($parser);
$configString = file_get_contents('config.yaml');
$config = ConfigFactory::create(Yaml::parse($configString));
$twig = new Environment(new FilesystemLoader('templates/'));
$controller = new Controller($factory, $twig, $config);
$router = new Router($controller);
$response = $router->route($_SERVER['PATH_INFO']);
echo $response;
}
catch (Throwable $e) {
// Here for debugging purposes
echo 'Exception: '. $e->getMessage();
}