Add the Home page

This commit is contained in:
Oliver Davies 2020-12-26 21:45:49 +00:00
parent 559ed8e908
commit cdb0e67eb3
4 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,17 @@
<?php
declare(strict_types=1);
namespace App\Controller;
use Twig\Environment;
abstract class BaseController
{
protected Environment $twig;
public function __construct(Environment $twig)
{
$this->twig = $twig;
}
}

View file

@ -0,0 +1,21 @@
<?php
declare(strict_types=1);
namespace App\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
final class HomeController extends BaseController
{
/**
* @Route("/", name="home")
*/
public function __invoke(): Response
{
$content = $this->twig->render('pages/home.html.twig');
return new Response($content);
}
}

5
templates/page.html.twig Normal file
View file

@ -0,0 +1,5 @@
{% extends 'html.html.twig' %}
{% block body %}
{% block content %}{% endblock %}
{% endblock %}

View file

@ -0,0 +1,5 @@
{% extends 'page.html.twig' %}
{% block content %}
This is the homepage.
{% endblock %}