The callback receives the type of output (out or err) and some bytes
from the output in real-time while writing the standard input to the process.
It allows to have feedback from the independent process during execution.
use Symfony\Component\Process\Process; $process = new Process(['ls', '-la']); $process->start(); // Wait for the process to finish $process->wait(); echo $process->getOutput();
use Symfony\Component\Process\Process; $command = 'php -r "echo \'Hello World\'; sleep(5);"'; $process = new Process($command); $process->start(); // Wait up to 10 seconds for the process to finish if (!$process->wait(10)) { // The process did not finish within 10 seconds $process->stop(); } echo $process->getOutput();In this example, a new process is started to echo "Hello World" and then sleep for 5 seconds before finishing. The `wait` method is called with a timeout value of 10 seconds, which means that if the process does not finish within that time period, it will be forcibly stopped using the `stop` method. Package Library: Symfony\Component\Process.