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.

Episodes