We run node.js CLI script from PHP with Symfony Process.
The script always print whole response as JSON in one line.
The response is somehow truncated on 512 characters.
I only found that xdebug.var_display_max_data => 512 => 512
in php.ini
but don't see how this is related.
Adapter > Symfony Process > node script.js
A) Test Node script
- from terminal node script
$ node user-update.js parameters
returns full result in all cases - like 629 chars. - from Symfony Process node script response is truncated to 512 chars.
B) Test Symfony Process
$process = new Process($cmd);
try {
$process->mustRun();
$response = $process->getOutput();
} catch (ProcessFailedException $e) {
$response = $e->getMessage();
}
echo $response;
echo PHP_EOL;
echo strlen($response);
-
$cmd = 'node user-update.js parameters';
- truncated to 512. -
$cmd = 'php -r \'for($i=0; $i<520; $i++){ echo "."; }\'';
- does not truncate. -
$cmd = 'cat long_one_line.txt';
- print full file. 1650 chars in one line.
C) Try with PHP shell functions
$response = shell_exec($cmd); // response is truncated to 512
system($cmd, $returnVal); // print directly to STDOut, truncated to 512
What could be the cause and solution?
- node v7.6.0
- PHP 7.1.2