-
Notifications
You must be signed in to change notification settings - Fork 289
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
Unable to retrieve parameters from PUT method #203
Comments
I have no problem sending data using PUT. Check the examples. Are you trying to retrive JSON data or form data? |
@alexanis, I'm sending a curl request (with a PUT method) to a server running Klein. When I try to retrieve the parameters using |
@matthewgovaere The parameters aren't automatically parsed from the request body using in Klein. Since request body's can have multiple formats/content-types (multipart/form-data, application/json, application/x-www-form-urlencoded, etc.) the Klein library doesn't try to parse the parameters for you based on the content-type. However, PHP will do this when using multipart/form-data (what goes in the $_POST var), so the library will use those parameters by default. I may add parameter parsing by default, but since they can have a pretty opinionated parsing process I may make it optional or configurable somehow. Until then, you'll have to parse the parameters yourself. |
I put this code (found via SO) in my base controller class.
Then you access the data like so.
EDIT: I had to make a change to handle empty $matches. I also made an $a_data object instead of array, as I like object syntax better for this to match Klein's style. This probably doesn't handle every data type you can PUT. It works perfectly fine for form-data. |
Unable to retrieve parameters from the method 'PUT' using
$request->params()
. I'm assuming that the 'DELETE' method has the same issue.Am I missing something? If not, I may be able to help add it in.
The text was updated successfully, but these errors were encountered: