-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] $request->body->get #47646
Comments
this is not about adding support for XML, YAML, etc. though i'd fundamentally agree it should be possible to add later ideally the parsing happens in a lazy manner, thus a LazyInputBag or so |
I also remember this being quite confusing when I started working with Symfony back then, especially as the variable itself most often is named |
@symfony/mergers any thoughts on this. I really like the idea. I think it's common to want to get the array of data from a request and not care if it's a form request or json. My only hesitation is the name One idea @ro0NL had is to perhaps deprecate |
I would love to clarify the |
I agree as well that it’s worth renaming. |
Me too 👍 |
I like the idea of renaming |
This issue has sort of morphed into three things.
|
Yes, you are absolutely right. There are exactly these 3 topics here in this issue. Thanks for clarifying. |
My preference goes for |
Now, do you think |
I would love if For backward-compatibility, we cannot do the same for |
i understand if this is too disruptive also i realized for us the better path is to deserialize requests into dedicated (message) DTOs, and dispatch from there |
I think we should keep this issue open, or at least close as completed. We have an open PR about this (#47938) that we should continue, we can do this in a non disruptive way. |
This PR was merged into the 6.3 branch. Discussion ---------- [HttpFoundation] add `Request::getPayload()` | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | Fix #47646 | License | MIT | Doc PR | todo Alternative for #47938 based on feedback there. ```php /** `@var` InputBag $input wrapping either Request::$request or Request::toArray() */ $input = $request->getPayload(); ``` Commits ------- 4a0a439 [HttpFoundation] add `Request::getPayload()`
Description
Hi,
I'd like to propose
$request->body->get()
(anInputBag
) to provide uniform access to a structured request body payload, regardless of content-type.$request->request
always looked weird to me, and is bound to$_POST
, thusapplication/x-form-urlencoded
:symfony/src/Symfony/Component/HttpFoundation/Request.php
Line 293 in ed1b002
Then for
application/json
one needstoArray()
:symfony/src/Symfony/Component/HttpFoundation/Request.php
Line 1502 in ed1b002
Example
The text was updated successfully, but these errors were encountered: