-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
38 lines (26 loc) · 840 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
<?php
/* Entry point to Slim 3 MVC application */
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
require 'vendor/autoload.php';
require 'config.php';
// Get container
$container = $app->getContainer();
// USING PHP-VIEW
// Register component on container
$container['view'] = function ($container) {
return new \Slim\Views\PhpRenderer('./mvc/views/_templates/');
};
// Render template in route
$app->get('/', function ($request, $response) {
return $this->view->render($response, 'index.html');
});
// Render PHP template in route
$app->get('/hello/{name}', function ($request, $response, $args) {
return $this->view->render($response, 'profile.html', [
'name' => $args['name']
]);
})->setName('profile');
// Run app
$app->run();
//That's it!