Skip to content

ServerRequest: withParsedBody Example

Terry L edited this page Jun 20, 2020 · 3 revisions
Clone this wiki locally

Shieldon\Psr7\ServerRequest

Extends Request.

withParsedBody($data)

Return an instance with the specified body parameters.

  • param null|array|object $data * The deserialized body data.
  • return static

Example:

$serverRequest = $serverRequest->withParsedBody(
    [
        'foo' => 'bar',
        'yes' => 'I do'
    ]
);

$parsedBody = $serverRequest->getParsedBody();

echo $parsedBody['yes'];
// Outputs: I do