Skip to content

Commit cf30edd

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: [Process] add docs for ExecutableFinder
2 parents 1b9fd9d + 51ff95d commit cf30edd

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
@@ -498,10 +498,32 @@ Use :method:`Symfony\\Component\\Process\\Process::disableOutput` and
498498
However, it is possible to pass a callback to the ``start``, ``run`` or ``mustRun``
499499
methods to handle process output in a streaming fashion.
500500

501+
502+
Finding an Executable
503+
---------------------
504+
505+
The Process component provides a utility class called
506+
:class:`Symfony\\Component\\Process\\ExecutableFinder` which finds
507+
and returns the absolute path of an executable::
508+
509+
use Symfony\Component\Process\ExecutableFinder;
510+
511+
$executableFinder = new ExecutableFinder();
512+
$chromedriverPath = $executableFinder->find('chromedriver');
513+
// $chromedriverPath = '/usr/local/bin/chromedriver' (the result will be different on your computer)
514+
515+
The :method:`Symfony\\Component\\Process\\ExecutableFinder::find` method also takes extra parameters to specify a default value
516+
to return and extra directories where to look for the executable::
517+
518+
use Symfony\Component\Process\ExecutableFinder;
519+
520+
$executableFinder = new ExecutableFinder();
521+
$chromedriverPath = $executableFinder->find('chromedriver', '/path/to/chromedriver', ['local-bin/']);
522+
501523
Finding the Executable PHP Binary
502524
---------------------------------
503525

504-
This component also provides a utility class called
526+
This component also provides a special utility class called
505527
:class:`Symfony\\Component\\Process\\PhpExecutableFinder` which returns the
506528
absolute path of the executable PHP binary available on your server::
507529

0 commit comments

Comments
 (0)