POSTing 101

This video is available to view for members only.

Click here to Join!

Already a member?


Getting data out of Symfony REST API is one thing, but there's a strong chance that you will also need to add new data.

That's where the POST verb comes in to play.

In this video we will look at how to set up a basic POST action in FOS REST Bundle. The way we do this is to take the standard Symfony Request object that we get for free in our Controller actions and then use the Symfony Form component to do all the hard work.

The form component? I hear you say. But, we aren't doing anything with forms? And that's really where the magic of this methodology comes in to play. Well, it's not magic. It's actually pretty straightforward, but it's clever all the same, and likely not a way that you've thought about using the form component before.

We're going to start off adding all the logic into our Controller. That's a bit yacky, but stick with it as keeping it simple gives us a good basis for understanding the whole workflow. We can extract and modularise once we know it all works.

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