The $HTTP_RAW_POST_DATA
is out of use from version 5.6 underlined text, what causes the Warning, as described in the documentation:
This message specifies Automatically populating $HTTP_RAW_POST_DATA
occurs when the php.ini
is configured 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 no longer exists, 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 the use of $HTTP_RAW_POST_DATA
one can use the wrappers
, in case to take the input data we use php://input
A simple example:
<?php
$postdata = file_get_contents('php://input');
If the data is too large (extensive) you can make a "loop" for reading, example of how to write the data in 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 the warnings and still use $HTTP_RAW_POST_DATA
, but from PHP7 it no longer works, as said before, so prefer from now use Wrappers to maintain compatibility.