Ajout controlleur et templates

This commit is contained in:
Aymeric SERRA 2023-02-06 14:29:20 +00:00
parent f672d37ed2
commit 3cac46ea39
2 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,18 @@
<?php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class PagesController extends AbstractController
{
#[Route('/pages', name: 'app_pages')]
public function index(): Response
{
return $this->render('pages/index.html.twig', [
'controller_name' => 'PagesController',
]);
}
}

View File

@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}
{% block title %}Hello PagesController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/var/www/html/cc34/src/Controller/PagesController.php'|file_link(0) }}">src/Controller/PagesController.php</a></code></li>
<li>Your template at <code><a href="{{ '/var/www/html/cc34/templates/pages/index.html.twig'|file_link(0) }}">templates/pages/index.html.twig</a></code></li>
</ul>
</div>
{% endblock %}