GET Handled, thin Controllers and fun with Services

This video is available to view for members only.

Click here to Join!

Already a member?

Login


In an effort to keep our controllers thin, and to maintain our sanity as our projects grow larger, it becomes increasingly more important to shift logic out of our Symfony Controller and into a designated Handler class.

The idea behind our Handler class is that we want to abstract the whys and wherefores of where our data is actually coming from. Ultimately it's not the Controller's job to care about such things. So we pass the responsibility over to a specific Handler class which implements a common Handler interface.

At first this looks like you're creating way more code to handle (ahem, no pun intended) quite a simple task. And there is some truth to that. Really this methodology only starts to show its benefits as your projects grow - which they always seem to do in the real world, if the project is making money for the business.

This is really laying the foundations for the rest of our project. All our end points will use and re-use the various Handlers that we create, and in doing so, we can keep our code DRY and ensure shared logic only ever exists in one place.

By the end of this video you will have gained a good understanding of how to structure a real world RESTful API project in Symfony 2 using the FOS REST Bundle.


Code For This Course

Get the code for this course.

Share This Episode

If you have found this video helpful, please consider sharing. I really appreciate it.


Episodes in this series

# Title Duration
1 GETting Started 17:06
2 GETting Refactored 15:39
3 GET Handled, thin Controllers and fun with Services 17:49
4 Automatic Route Generation 11:32
5 GETting a Collection 12:53
6 POSTing 101 11:06
7 Acceptance Testing our POST Method 05:40
8 Unit Testing our Symfony Form 22:55
9 Implementing and Testing the Form Handler 03:01
10 POST Form Handler Implementation 11:12
11 PUT Introduction 07:34
12 PUT Implementation 15:25
13 Pragmatic PATCH 15:17
14 DELETE'ing Things 03:30