-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
33 lines (28 loc) · 843 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
<?php
/**
* @file
* Temporary home page to test functionality.
*/
// Initializes the autoloader generated by composer.
$loader = require 'vendor/autoload.php';
$loader->addPsr4('Oop\\', __DIR__ . '/src');
$loader->register();
use Oop\Core;
use Oop\Controller\PostCollectionPage;
use Oop\Controller\HomepagePage;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\Routing\Loader\YamlFileLoader;
$request = Request::createFromGlobals();
// Our framework is now handling itself the request.
$app = new Core();
$app->map('/', function () {
$page = new HomepagePage();
return $page->homepage();
});
$app->map('/posts/{type}', function ($type) {
$page = new PostCollectionPage();
return $page->displayPosts($type);
});
$response = $app->handle($request);
$response->send();