9951 explained code solutions for 126 technologies


php-symfonyHow to access the PHP input stream in Symfony?


The PHP input stream can be accessed in Symfony using the getContent() method of the Request object.

Example code

$request = Request::createFromGlobals();
$inputStream = $request->getContent();

The getContent() method returns the raw request body, which is the input stream.

Code explanation

  • Request::createFromGlobals(): creates a new Request object from the PHP global variables
  • getContent(): returns the raw request body, which is the input stream

Helpful links

Edit this code on GitHub