File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -230,6 +230,29 @@ stream resources or Traversable objects as argument. As shown in the above examp
230
230
you need to explicitly call the :method: `Symfony\\ Component\\ Process\\ InputStream::close `
231
231
method when you are done writing to the standard input of the subprocess.
232
232
233
+ Using PHP Streams as the Standard Input of a Process
234
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
235
+
236
+ The input of a process can also be defined using `PHP streams `_::
237
+
238
+ $stream = fopen('php://temporary', 'w+');
239
+
240
+ $process = new Process('cat');
241
+ $process->setInput($stream);
242
+ $process->start();
243
+
244
+ fwrite($stream, 'foo');
245
+
246
+ // ... read process output or do other things
247
+
248
+ fwrite($stream, 'bar');
249
+ fclose($stream);
250
+
251
+ $process->wait();
252
+
253
+ // will echo: 'foobar'
254
+ echo $process->getOutput();
255
+
233
256
Stopping a Process
234
257
------------------
235
258
@@ -420,3 +443,4 @@ Use :method:`Symfony\\Component\\Process\\Process::disableOutput` and
420
443
.. _`pid` : https://en.wikipedia.org/wiki/Process_identifier
421
444
.. _`PHP Documentation` : http://php.net/manual/en/pcntl.constants.php
422
445
.. _Packagist : https://packagist.org/packages/symfony/process
446
+ .. _`PHP streams` : http://www.php.net/manual/en/book.stream.php
You can’t perform that action at this time.
0 commit comments