Chapter 2 of the Symfony for PHP developers track
The cellar and the pantry
6 exercises · 1,080 XP · about 2 h 45 min
EntityMappingDoctrineRepositoryDependency injectionConsole commandQueryBuilderDQLParameterspersistSluggerManyToOneOneToManyRelationsDebuggingschema:validate
The chapter's exercises
-
Bruna's ledger
Exercise 1 · 150 XP · 5 objectives checked by tests
Booking was a smash hit: the tavern is never empty. Bruna wants to add to her menu every week, but adding a dish means… changing the code. Unacceptable. From now on, the dishes will live in a database.
EntityMappingDoctrine
-
The menu comes out of the database
Exercise 2 · 150 XP · 5 objectives checked by tests
The Plat entity exists, and so does the table. Bruna even wrote a command to fill her menu: app:charger-carte (load the menu). Every time the preview loads, the console runs for you:
RepositoryDependency injectionConsole command
-
A tailor-made query
Exercise 3 · 150 XP · 5 objectives checked by tests
The broke adventurers are complaining: there's no way to tell what six gold pieces will buy. And Gorm would like the “dish of the day” to be the cheapest specialty, to draw in the customers.
QueryBuilderDQLParameters
-
Bruna invents a dish
Exercise 4 · 180 XP · 5 objectives checked by tests
Bruna has an idea a day, and she's tired of going through SQL in the console. She wants a page to add her dishes: /kitchen/new-dish. The form is ready, and the navigation already leads to it (the “Kitchen” link).
persistSlugger
-
A place for every dish
Exercise 5 · 200 XP · 5 objectives checked by tests
With Bruna's inventions, the menu keeps growing… and nobody can find anything anymore: the Captain's Grog sneaks in between two stews. Gorm wants a menu sorted by category: main courses, sides, drinks.
ManyToOneOneToManyRelations
-
🐉 Boss: the flooded cellar
Exercise 6 · 250 XP · 5 objectives checked by tests
A pipe burst: the cellar is under water, and Gorm had to call for backup. Guess who came to “help”? Pippin. Since then:
Debuggingschema:validate