The $HTTP_RAW_POST_DATA
is deprecated as of version 5.6 bolded , which causes warning as described in the documentation:
This message specifies Automatically populating $HTTP_RAW_POST_DATA
occurs when php.ini
is set to automatically generate the variable $HTTP_RAW_POST_DATA
through the flag always_populate_raw_post_data
.
The always_populate_raw_post_data
by default is On in older versions of PHP, but in PHP7 it does not exist anymore, so the problem will not occur if your PHP is an older version, so just set up php.ini like this:
always_populate_raw_post_data=-1
Save and restart Apache / Ngnix / Lighttpd.
As an alternative to using $HTTP_RAW_POST_DATA
you can use wrappers
, in the case to get the input data we use php://input
A simple example:
<?php
$postdata = file_get_contents('php://input');
If the data is very large (extensive) you can do a "loop" for reading, example of how to write the data to a file:
<?php
$fileHandle = fopen('arquivo.txt', 'wb');
$inputHandle = fopen('php://input', 'rb');
if ($fileHandle && $inputHandle) {
while(FALSE === feof($inputHandle)) {
$data = fgets($inputHandle, 256);
fwrite($fileHandle, $data);
}
fclose($fileHandle);
fclose($inputHandle);
}
Note that you can turn off warnings and still use $HTTP_RAW_POST_DATA
, but as of PHP7 it does not work any more, in> to maintain compatibility.