I have been exploring serverless php for and I opted on using slim framework because I find it easier to just plugin modules as I go and that what I am building is just landing pages with a few forms. So I have made the landing pages on slim framework and had it working on traditional servers like micro instances but when I migrated it on serverless php specifically using bref but the post method does not seem to work anymore.
I consume the API I made using slim + bref serverless via AJAX. I passed the contentType : application/json
, with a POST
method but still not working.
I have used the following methods:
$request->getParsedBody()
-> this works fine on a non-serverless framework. But on serverless php bref it went "internal server error"$_POST
-> works fine locally and traditional servers but on cloudwatch and var_dumping it is empty array.$request->getParams()
(not working no method of that is existing but I saw it here in Stackoverflow)The work around I found was to have it on GET method but I actually want to use POST method because I'd like to use it on passwords.
Anyone who has experienced the same?
Thanks
I will just update the question because I just figured it out, I was using jquery AJAX call. I did use contenType :application/json' but it is not working BUT when I did not use ajax and just simply submit the form, the posted data appeared on cloudwatch and got dumped. I guess for some unkown reason it does not work on AJAX(I did try it on postman too,but no luck). I even tried the file_get_contents("php://input") to get posted json but still not working. Will just stick to page reloading.Thanks again!