40 lines
994 B
PHP
40 lines
994 B
PHP
<?php
|
|
use Slim\Factory\AppFactory;
|
|
use DI\Container as Container;
|
|
use Psr\Http\Message\ResponseInterface as Response;
|
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
|
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
$container = new Container;
|
|
|
|
$settings = require __DIR__ . '/../app/settings.php';
|
|
$settings($container);
|
|
|
|
// Set view in Container
|
|
$container->set('view', function() {
|
|
return Twig::create(__DIR__ . '/../templates',
|
|
['cache' => __DIR__ . '/../cache']);
|
|
});
|
|
|
|
AppFactory::setContainer($container);
|
|
|
|
$app = AppFactory::create();
|
|
|
|
$middleware = require __DIR__ . '/../app/middleware.php';
|
|
$middleware($app);
|
|
|
|
// Routes
|
|
$app->get('/', function (Request $request, Response $response, $args) {
|
|
$response->getBody()->write("Hello Nick!");
|
|
return $response;
|
|
});
|
|
|
|
$app->get('/twig', function (Request $request, Response $response, $args) {
|
|
return $this->get('view')->render($response, 'hello.twig', [
|
|
'name' => $args['name']
|
|
]);
|
|
});
|
|
|
|
|
|
$app->run(); |