Skip to content

Documented the PhpExecutableFinder utility #9182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions components/process.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,22 @@ Use :method:`Symfony\\Component\\Process\\Process::disableOutput` and
Moreover, you could not pass a callback to the ``start()``, ``run()`` or ``mustRun()``
methods or use ``setIdleTimeout()``.

Finding the Executable PHP Binary
---------------------------------

This component also provides a utility class called
:class:`Symfony\\Component\\Process\\PhpExecutableFinder` which returns the
absolute path of the executable PHP binary available on your server. It looks
for the PHP executable using environment variables like ``PHP_BINARY``,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this sentence: it is inaccurate, and it's complex to explain accurately
let just describe what it does, not how

``PHP_PATH``, ``PHP_PEAR_PHP_BIN``, ``PHP_BINDIR``, etc. and returns the first
available binary::

use Symfony\Component\Process\PhpExecutableFinder;

$phpBinaryFinder = new PhpExecutableFinder();
$phpBinaryPath = $phpBinaryFinder->find();
// $phpBinaryPath = '/usr/local/bin/php' (the result will be different on your computer)

.. _`Symfony Issue#5759`: https://github.com/symfony/symfony/issues/5759
.. _`PHP Bug#39992`: https://bugs.php.net/bug.php?id=39992
.. _`exec`: https://en.wikipedia.org/wiki/Exec_(operating_system)
Expand Down