Skip to content

Commit 64abbe6

Browse files
committed
Merge branch '5.2' into 5.x
* 5.2: [Process] add docs for ExecutableFinder
2 parents 9826412 + f978006 commit 64abbe6

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

components/process.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,32 @@ Use :method:`Symfony\\Component\\Process\\Process::disableOutput` and
513513
However, it is possible to pass a callback to the ``start``, ``run`` or ``mustRun``
514514
methods to handle process output in a streaming fashion.
515515

516+
517+
Finding an Executable
518+
---------------------
519+
520+
The Process component provides a utility class called
521+
:class:`Symfony\\Component\\Process\\ExecutableFinder` which finds
522+
and returns the absolute path of an executable::
523+
524+
use Symfony\Component\Process\ExecutableFinder;
525+
526+
$executableFinder = new ExecutableFinder();
527+
$chromedriverPath = $executableFinder->find('chromedriver');
528+
// $chromedriverPath = '/usr/local/bin/chromedriver' (the result will be different on your computer)
529+
530+
The :method:`Symfony\\Component\\Process\\ExecutableFinder::find` method also takes extra parameters to specify a default value
531+
to return and extra directories where to look for the executable::
532+
533+
use Symfony\Component\Process\ExecutableFinder;
534+
535+
$executableFinder = new ExecutableFinder();
536+
$chromedriverPath = $executableFinder->find('chromedriver', '/path/to/chromedriver', ['local-bin/']);
537+
516538
Finding the Executable PHP Binary
517539
---------------------------------
518540

519-
This component also provides a utility class called
541+
This component also provides a special utility class called
520542
:class:`Symfony\\Component\\Process\\PhpExecutableFinder` which returns the
521543
absolute path of the executable PHP binary available on your server::
522544

0 commit comments

Comments
 (0)