-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
40 lines (29 loc) · 978 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
36
37
38
39
40
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once 'vendor/autoload.php';
$routes = require 'config/route.php';
$container = require 'container.php';
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
$request = Request::createFromGlobals();
$context = new RequestContext();
$context->fromRequest($request);
$matcher = new UrlMatcher($routes, $context);
try
{
$parameters = $matcher->match($request->getPathInfo());
$studentRepository = $containerBuilder->get('student_repository');
$controller = new $parameters['_controller']($studentRepository, $parameters);
/** @var Response $response */
$response = call_user_func($controller);
$response->send();
}
catch (\Exception $e)
{
http_response_code(500);
throw $e;
echo 'Une exception a été lancée. Message d\'erreur :' . $e->getMessage();
}