The guestbook's fame has spread across Middle-earth: Bruna wants a page that gathers all the reviews, for every dish. Pippin wrote it (/guestbook, in LivreDOrController, the guestbook controller), the template is ready, but the page shows every review at once. There are already about fifty of them, and it will soon be unreadable.
Your mission
Split the guestbook into pages of 10 reviews, newest first:
/guestbookshows the 10 newest reviews, the total (“50 reviews from travelers”) and “Page 1 of 5”;/guestbook?page=2shows the next 10: no review skipped, none twice;- a page that does not exist (
?page=9,?page=0,?page=abc) responds 404; - the template's “Older” and “Newer” links work;
- the database returns only the reviews on the page, in 3 queries at most.
The reviews (Avis) are read through AvisRepository; each one has its creeLe (created at) date and its plat (dish).
Paginating means asking less of the database
Fetching 50 reviews to show only 10 works today, but not with 50,000. The database knows how to limit what it returns (LIMIT, OFFSET), and Doctrine asks it for you. One question remains: how many pages are there? To find out, you have to count all the reviews, and that's another query.