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