You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Begun on a small PR for doc, now it's time to tackle this old issue on the PHP side.
I discuss this topic on the Symfony issues' side, and will not copy/paste the discussion here. But as API-Platformers are more willing to profit from this change, you may have very interesting insights and knowledge.
I was wondering about the PATCH method, so let's go with an example:
Imagine that you have a resource (a Pokemon), with few properties (name, id, type, ...), and one of them is an image (sprite). For design purpose, as there is a 1to1 relationship between a Pokemon and a Sprite, there is no need to expose a sprite as a resource. The only liberty you can take is that a Pokemon can have 0 or 1 sprite (nullable).
POST will be OK at this point, because you send (multipart/form-data) your new pokemon with every properties, and you embed the sprite img with. It actually works, no discussion here.
PUT is harder, as you will need to send all the data back, and maybe erase few dynamic properties (updated_at).
PATCH is the way to go, as you maybe want to update your pokemon resource later with your brand new version of its sprite.
Is my example a practical use case?
Is it possible to edit just this property by sending a file?
What about changing its type AND its sprite in a single request? What will be the Content-type?
Is it allowed to request PATCH with another Content-Type than "merge/patch+json"?
How would you ask PHP to behave to improve usability?
Do you think that PHP should:
adhere more to the HTTP protocol (for example if you use a PUT verb, PHP should reflect this with a $_PUT superglobal, and 1 superglobal by official verbs) or standards?
be more agnostic (for example accept file uploads whatever the verb or the Content-Type used) about how protocols or standards evolve?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Begun on a small PR for doc, now it's time to tackle this old issue on the PHP side.
I discuss this topic on the Symfony issues' side, and will not copy/paste the discussion here. But as API-Platformers are more willing to profit from this change, you may have very interesting insights and knowledge.
I was wondering about the PATCH method, so let's go with an example:
POST will be OK at this point, because you send (multipart/form-data) your new pokemon with every properties, and you embed the sprite img with. It actually works, no discussion here.
PUT is harder, as you will need to send all the data back, and maybe erase few dynamic properties (updated_at).
PATCH is the way to go, as you maybe want to update your pokemon resource later with your brand new version of its sprite.
Beta Was this translation helpful? Give feedback.
All reactions