
Create Three Symfony Back Ends - Part #11 - GET lots of resources
Feb 14, 2023
We have covered how to GET a single Album by ID. We saw that we would need to have injected the AlbumRepository, and that we could use the Symfony routing annotations to ensure we only got ID's that were numerical.
With that numerical value we could ask the repository for the Album entity matching the given ID, and then return that as JSON, with a little detour through the jsonSerialize method.
As it turned out, GETting just a single Album wasn't that hard.
And Good News Everybody! Getting a collection of Albums is really straightforward. We've done all the hard work.
There's two things we need to do:
Make sure we use a slightly different name for our route.
Switch the AlbumRepository method call from find to findAll.
Honestly, both of these are super straightforward - it's basically a case of copy / paste the existing get method, and make some small adjustments.
Show More Show Less #Music Streams & Downloads
#Music Art & Memorabilia
