Chapter 1 of the Symfony for PHP developers track

First steps at the tavern

8 exercises · 1,040 XP · about 3 h · free first chapter

This chapter works on: ControllerRouteTwigRoute parameter404Twig loopFiltersConditionsTwig inheritanceincludepath()Query string#[MapQueryParameter]ValidationPOSTRedirectFlash messagesServiceAutowiringDependency injectionDebuggingError pagesProfiler

The chapter's exercises

  1. The tavern opens its doors

    Exercise 1 · 100 XP · 5 objectives checked by tests

    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!

    ControllerRouteTwig

  2. The dish of the day

    Exercise 2 · 100 XP · 4 objectives checked by tests

    The menu is a hit. So much so that adventurers now want to know everything about each dish before ordering. Gorm wrote the list of dishes in the MenuController::PLATS constant (plats = dishes), each one identified by a URL identifier (the slug). Each dish has a nom (name), a description, a prix (price) and a specialite (specialty) flag.

    Route parameter404

  3. Prices in gold pieces

    Exercise 3 · 100 XP · 4 objectives checked by tests

    A goblin accountant has complained: the menu doesn't show the prices. Outrageous. Gorm asks you to redo the menu in Twig, and to show off his specialties while you're at it.

    Twig loopFiltersConditions

  4. One sign for every page

    Exercise 4 · 120 XP · 5 objectives checked by tests

    Adventurers find their way to /menu… but the tavern's front door, /, leads nowhere. And there's no way to get from one page to another. Time to hang one sign for every page.

    Twig inheritanceincludepath()

  5. How many adventurers?

    Exercise 5 · 120 XP · 4 objectives checked by tests

    Saturday night, the Fellowship of the Ring showed up unannounced: nine adventurers, three tables, zero seats. Gorm wants people to be able to book. First step: a page that announces the table for the number of guests given in the address, for example /reservation?personnes=4 (personnes = people).

    Query string#[MapQueryParameter]Validation

  6. The reservation

    Exercise 6 · 150 XP · 4 objectives checked by tests

    Announcing the table is nice. Booking it is better. Gorm drew up the form (already in the template): it sends a nom (name) and a number of personnes (people) via POST. Your job is to handle it.

    POSTRedirectFlash messages

  7. The head cook

    Exercise 7 · 150 XP · 5 objectives checked by tests

    Gorm finally hires a cook: Bruna, a dwarf who flatly refuses to let the list of dishes lie around the dining room (read: in the controller). The kitchen is her domain.

    ServiceAutowiringDependency injection

  8. 🐉 Boss: trouble in the kitchen

    Exercise 8 · 200 XP · 5 objectives checked by tests

    Gorm went off to the troll fair for two days and left the website to his nephew, Pippin. Pippin “improved a couple of things”. Result: nothing works anymore, adventurers are lining up in front of an error page, and a customer swears he ordered a grilled unicorn… and got served one.

    DebuggingError pagesProfiler