PUT and POST request data poorly documented

Skip to first unread message

Bill Dickson

Nov 24, 2022, 9:49:22 PM11/24/22
to Fat-Free Framework
I am new to F3 and am starting to use it as a lightweight router for a REST backend to a single page app after tiring of how SLIM has become anything but SLIM, and SLIM v2 (which was actually slim) no longer works in PHP 8.1.

I am wondering why I had to dig deep into stack overflow to learn that in order to get variables from a PUT request, I have to do this:

parse_str($f3->get('BODY'), $p);

POST is certainly easier,

$params = $f3['REQUEST'];

Shouldn't this stuff be more prominent in the docs?  Or am I using F3 unwisely?

Austin Collier

Nov 24, 2022, 11:23:33 PM11/24/22
to Bill Dickson via Fat-Free Framework
PUT and DELETE are not part of the html spec so there isn't such a
thing as $f3['PUT']; Additionally PUT and DELETE methods are not
handled in <form> tags but really only handled with ajax calls through
JavaScript. As such, typically the way that variables are passed are
like you mentioned, either parsing the body out, or using JSON instead
and decoding the JSON. I would say though that JSON is more common
than passing body params like a POST request.

On 11/24/22, Bill Dickson via Fat-Free Framework
> --
> -- You've received this message because you are subscribed to the Google
> Groups group. To post to this group, send an email to
> f3-fra...@googlegroups.com. To unsubscribe from this group, send an email
> to f3-framework...@googlegroups.com. For more options, visit this
> group at https://groups.google.com/d/forum/f3-framework?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Fat-Free Framework" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to f3-framework...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/f3-framework/657e824f-783d-4e81-a440-9e0651df5becn%40googlegroups.com.

Bill Dickson

Nov 25, 2022, 6:15:16 PM11/25/22
to Fat-Free Framework
Thanks much for the insight on this. 
I was (mistakenly) sending the ajax call Content Type : application/x-www-form-urlencoded which was generating the name/ value body.  By sending it Content Type: application/json, the body is the json string, and then on the server json_decode($f3->get('BODY')) does the job elegantly.
Thanks again for your reply.  I am still wondering if F3 is more than I need when all I'm doing is routing ajax data calls. 
Reply all
Reply to author
0 new messages