Slim 3 getParsedBody() always null and empty

animatorist picture animatorist · Feb 13, 2017 · Viewed 13.1k times · Source

I'm am using the Slim Framework Version 3 and have some problems.

$app-> post('/', function($request, $response){
  $parsedBody = $request->getParsedBody()['email'];
  var_dump($parsedBody);
});

result is always:

null

Can you help me ?

Answer

Thomas picture Thomas · Nov 12, 2019

When I switch to slimframework version 4, I had to add :

$app->addBodyParsingMiddleware();

Otherwise the body was always null (even getBody())