PUT Introduction

This video is available to view for members only.

Click here to Join!

Already a member?

Login


In this video we are going to be looking at the PUT verb of our Symfony 2 and FosRestBundle API.

As a high level overview, PUT would be used to completely replace an existing record in our database OR it would be create a new record for us, if the ID we are PUT'ting to does not already exist.

We are going to start with some failing tests and work our way through until they are all passing.

Firstly we will want to ensure that a PUT with both an invalid ID and invalid data should fail gracefully with a 400 error code.

Secondly, we want to ensure that even if we use an invalid ID but are submitting valid data that the data should be kept and a valid ID assigned and returned.

Thirdly, we want to ensure that invalid data cannot be PUT over the top of an existing valid id / record.

And lastly we want to ensure that if we have a valid ID and valid data, that the existing record is replaced entirely (keeping the same ID) with the submitted data.

By the end of this video you will have an established test base for implementing PUT into a Symfony2 FosRestBundle-based API.


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