The tavern opens its doors

Exercise 1 of 8 in chapter 1 · 100 XP · 5 objectives checked by tests

Topics covered: ControllerRouteTwig

Gorm, the innkeeper of the Drunken Dragon, is tired of reciting his menu to every adventurer who walks through the door. He wants a web page. You're the only one in the valley who can code: get to work!

The tavern's code was written by a French-speaking crew: classes, properties and route names are in French (Plat = dish, prix = price, nom = name…). You'll get used to it fast, and it's a good habit to work in a codebase you didn't name.

Your mission

  1. In MenuController, declare a route /menu named app_menu on the index() method.
  2. Make it render the template menu/index.html.twig, passing it a plats (dishes) variable: an array of three dishes of your own invention.
  3. In the template, display an <h1> title containing “menu”, then the dishes in a <ul class="plats"> list, using a Twig loop.

The preview on the right updates on every change. When you think you're done, run the tests: each objective you complete lights up.

Reminder

A Symfony controller is a plain PHP class. AbstractController gives you shortcuts such as render(), which turns a Twig template into a Response.