Chapter 5 of the Symfony for PHP developers track
Magic scrolls
6 exercises · 1,430 XP · about 4 h 30 min
JSON API$this->json()Serializer#[Groups]#[Groups] on a method#[Context]format: 'json'Problem JSONPOST JSONDTO#[MapRequestPayload]201 / 400 / 422access_tokenStateless firewallAccessTokenHandlerInterface401#[MapQueryString]EnumQueryBuildervalidationFailedStatusCodeDebuggingFirewallData leak
The chapter's exercises
-
The menu on a scroll
Exercise 1 · 200 XP · 5 objectives checked by tests
The Adventurers' Guild has just equipped its members with magic scrolls: they can browse the taverns of the region on them, book a table… Gorm wants the Drunken Dragon to be listed. The trouble is, scrolls can't read HTML: they speak JSON.
JSON API$this->json()Serializer#[Groups]
-
A dish on demand
Exercise 2 · 220 XP · 5 objectives checked by tests
The adventurers love having the menu on their scroll. Now they want to know what others think of a dish before ordering it (Gimli swears by it).
#[Groups] on a method#[Context]format: 'json'Problem JSON
-
Booking by pigeon
Exercise 3 · 240 XP · 5 objectives checked by tests
Big news: scrolls can now send messages. No need to cross the forest to book a table any more: a magic pigeon takes care of it. It brings a JSON like this one:
POST JSONDTO#[MapRequestPayload]201 / 400 / 422
-
The guild's seal
Exercise 4 · 250 XP · 5 objectives checked by tests
Disaster: some smart aleck has booked every table at the Drunken Dragon for the next ten years, under the name “Sauron”. Anyone can send a pigeon, and that's exactly the problem.
access_tokenStateless firewallAccessTokenHandlerInterface401
-
Filtering the menu
Exercise 5 · 240 XP · 5 objectives checked by tests
The Circle of Mages is on a diet: “Nothing above 4 gold pieces, and only drinks, thank you.” Rather than downloading the whole menu and sorting it themselves, the scrolls want to filter:
#[MapQueryString]EnumQueryBuildervalidationFailedStatusCode
-
🐉 Boss: the lost pigeon
Exercise 6 · 280 XP · 4 objectives checked by tests
Pippin is back from a crash course, “Scrolls in three days”. He has “simplified” a thing or two in the API.