@@ -352,6 +352,35 @@ The input of a process can also be defined using `PHP streams`_::
352
352
// will echo: 'foobar'
353
353
echo $process->getOutput();
354
354
355
+ Using TTY and PTY Modes
356
+ -----------------------
357
+
358
+ All examples above show that your program has control over the input of a
359
+ process (using ``setInput() ``) and the output from that process (using
360
+ ``getOutput() ``). The Process component has two special modes that tweak
361
+ the relationship between your program and the process: teletype (tty) and
362
+ pseudo-teletype (pty).
363
+
364
+ In TTY mode, you connect the input and output of the process to the input
365
+ and output of your program. This allows for instance to open an editor like
366
+ Vim or Nano as a process. You enable TTY mode by calling
367
+ :method: `Symfony\\ Component\\ Process\\ Process::setTty `::
368
+
369
+ $process = new Process(['vim']);
370
+ $process->setTty(true);
371
+ $process->run();
372
+
373
+ // As the output is connected to the terminal, it is no longer possible
374
+ // to read or modify the output from the process!
375
+ dump($process->getOutput()); // null
376
+
377
+ In PTY mode, your program behaves as a terminal for the process instead of
378
+ a plain input and output. Some programs behave differently when
379
+ interacting with a real terminal instead of another program. For instance,
380
+ some programs prompt for a password when talking with a terminal. Use
381
+ :method: `Symfony\\ Component\\ Process\\ Process::setPty ` to enable this
382
+ mode.
383
+
355
384
Stopping a Process
356
385
------------------
357
386
@@ -483,7 +512,6 @@ Use :method:`Symfony\\Component\\Process\\Process::disableOutput` and
483
512
However, it is possible to pass a callback to the ``start ``, ``run `` or ``mustRun ``
484
513
methods to handle process output in a streaming fashion.
485
514
486
-
487
515
Finding an Executable
488
516
---------------------
489
517
0 commit comments