Q:

Symfony3/PHP7 Issues with Request::getContent()

I've just started using Symfony.  I've put a test page (API) together and to get the JSON body being passed in I use Request:getContent().  This works well and as expected on my dev machine (Mac OS X 10.11.4, MAMP with PHP 5.6.10.  When I deploy to the test server, Ubuntu Server 16.04 LTS with PHP 7.0.4 it throws the error:
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Fatal error: Using $this when not in object context" at /var/www/html/symfony_api/var/bootstrap.php.cache line 1008 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Fatal error: Using $this when not in object context at /var/www/html/symfony_api/var/bootstrap.php.cache:1008)"} []

Simply commenting out the request line and using normal PHP to get the body using file_get_contents('php://input') caused the class to work as expected on both machines.
Thanks for any help.

A:

The getContent() metod is not static method of Request class (http://api.symfony.com/2.8/Symfony/Component/HttpFoundation/Request.html#method_getContent), use:
$request->getContent();

