Automatic Route Generation

Up until now we've been defining our routes in the usual Symfony manner. In this video we're going to look at how we can cut out a lot of the repetition from our routing.yml file and instead, allow FOS REST Bundle to look at our controllers and determine the available routes from the way our controller actions are named.

The one downside to doing this is that developers new to the project - or more specifically, new to FOS REST Bundle - are going to have an increased learning curve when trying to figure out how and why these routes seem to magically appear, yet aren't explicitly defined anywhere.

I wouldn't normally advocate changing something like this if you're already started with your implementation, but as we have being good TDD developers, we have a way of testing our REST API and as such, we can ensure we aren't going to break any existing functionality by implementing this new routing structure.

We're also going to take a look at the Request Format Listener, one of those scary sounding components that at first seem to add another layer of complexity to an already seemingly large and complex learning process.

Code For This Course

Get the code for this course.

Code For This Video

Get the code for this video.