Pragmatic PATCH

There's a well known post in the world of Symfony2 REST APIs entitled Please. Don't PATCH like an idiot.

I'm going to suggest you give that post a read as part of learning about how to implement PATCH in your FosRestBundle-based API.

Right now, there is no easy way to implement what is stated in that blog post / RFC. And whilst I agree with the sentiment, I would argue that the crude / simplistic approach to PATCH'ing as described in this video may suffice, depending on your environment. I have personally used a simplistic approach to PATCH'ing in two Symfony2+FosRestBundle production APIs and whilst neither are hugely trafficked, I have not had any problems with PATCH'ing (that I am aware of!).

The problem here is that it should be impossible for a consumer of our REST API to access (GET) a resource that is partially updated. Depending on how your API is used, the likelihood of this scenario may or may not be a concern for you.

So, with all that said, in this video I am going to show you how to PATCH like an idiot. Or to be less negative, consider this a pragmatic guide to PATCH.

If an when a better solution is released, I shall gladly update this tutorial.

Code For This Course

Get the code for this course.

Code For This Video

Get the code for this video.


# 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:24
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