GETting Refactored

Wait, what? We only just started and we are refactoring? What is this madness?

Absolutely we are refactoring. Keeping our code lean, mean, and green is vitally important to keep our project healthy and clean. It's also a breeze, because our awesome test suite has our back so we can refactor with confidence.

Even though it's very early days, our code is already starting to show signs of duplication, especially in our test suite. We want to eliminate as much duplication as possible, primarily for our own sanity, but also because we don't want to be changing multiple locations whenever parts of our code base changes.

Next up, we will cover the basics of documenting our API using the incredible Nelmio API Documentation bundle. This is used to generate some super nice API docs for us by way of our PHP DocBlocks. It's simple enough to use, and we will keep coming back to it throughout the course as we add and update our API end points.

Then we move on to FOS REST Bundle View Listeners. This is very similar in usage to the Sensio Framework Extra Bundle, which you may well have used for handy short cuts in your Symfony 2 controllers like routing annotations and param convertors. Inside FOS REST Bundle, the view listener is the way that our code will know whether to show a JSON response, or an XML response, or a HTML response - or whatever other kind of response we specify.

Ultimately, as mentioned in the intro to this course, the idea is that first we learn how FOS REST Bundle works in a verbose way, and then once we have an understanding of the basics, we can more confidently start using the short cuts to save time and save additional lines on unnecessary code.

Code For This Course

Get the code for this course.