Chapters
28 Chapters
|
1:45:06
|
This course is archived!
This tutorial uses a deprecated micro-framework called Silex. The fundamentals of REST are still valid, but the code we use can't be used in a real application.
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
18.
PUT Versus POST
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial uses a deprecated micro-framework called Silex. The fundamentals of REST are still valid, but the code we use can't be used in a real application.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"silex/silex": "~1.0", // v1.3.2
"symfony/twig-bridge": "~2.1", // v2.7.3
"symfony/security": "~2.4", // v2.7.3
"doctrine/dbal": "^2.5.4", // v2.5.4
"monolog/monolog": "~1.7.0", // 1.7.0
"symfony/validator": "~2.4", // v2.7.3
"symfony/expression-language": "~2.4" // v2.7.3
},
"require-dev": {
"behat/mink": "~1.5", // v1.5.0
"behat/mink-goutte-driver": "~1.0.9", // v1.0.9
"behat/mink-selenium2-driver": "~1.1.1", // v1.1.1
"behat/behat": "~2.5", // v2.5.5
"behat/mink-extension": "~1.2.0", // v1.2.0
"phpunit/phpunit": "~5.7.0", // 5.7.27
"guzzle/guzzle": "~3.7" // v3.9.3
}
}
5 Comments
Ok, so let's say that I have, in ALL my entities, a field called updated, that I use to track when that entity was "updated". So, in this case, I should never use PUT to edit this or any other entity in my project, right? Because if the resource always will return a different value for the updated field, it cannot be considered idempotent. Is that the idea?
Hey Carlos!
I admit, that is an interesting thought! There's an excellent answer about this here: https://stackoverflow.com/q...
The tl;dr is that the point of idempotency is to communicate to a client that repeating an operation is safe. And so, even though an updatedAt field might change on aa PUT request to your API, you would still consider it (on a philosophical level) as an "operation that could be repeated without side effects". So yes, it *is* ok to use PUT in this case, even though you have a valid point about the updatedAt. This is often what makes REST tricky: navigating the seemingly-strict rules vs reality.
Cheers!
Yess.. thank you again Ryan!!
Honestly, saying a thing and then writing another on the slides doesn't help so much...please be...consistent ;)
Hey Aristotele T.
Sorry about that. Could you tell at what point of the video that happens?
Cheers!
"Houston: no signs of life"
Start the conversation!