Closed
Description
I am trying to run the PHP buitin web server with Symfony\Component\Process\Process
and get its output but I'm having issue.
I think it's because php -S
does not print output in non tty mode (eg: php -S 127.0.0.1:8080 | cat
). So I tried to turn on tty on this process but this does not work either. after looking at the code, it seems that the private member tty
is not used anymore. it was added here : 2d30fb3#diff-f9f2411040cda7b73402481facf3e4dd but I can't find when it disappeared.
here is a small php file to test it :
<?php
require_once 'vendor/autoload.php';
use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Process\PhpExecutableFinder;
$finder = new PhpExecutableFinder;
$php = $finder->find();
$builder = new ProcessBuilder([$php, '-S', '127.0.0.1:48880']);
$builder->inheritEnvironmentVariables(true);
$process = $builder->getProcess();
$process->setTty(true);
$process->start();
sleep(2);
$output = $process->getOutput();
assert($output !== null);