Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. PhpExecutableFinder.php

function PhpExecutableFinder::find

Finds The PHP executable.

File

vendor/symfony/process/PhpExecutableFinder.php, line 32

Class

PhpExecutableFinder
An executable finder specifically designed for the PHP executable.

Namespace

Symfony\Component\Process

Code

public function find(bool $includeArgs = true) : string|false {
    if ($php = getenv('PHP_BINARY')) {
        if (!is_executable($php) && !($php = $this->executableFinder
            ->find($php))) {
            return false;
        }
        if (@is_dir($php)) {
            return false;
        }
        return $php;
    }
    $args = $this->findArguments();
    $args = $includeArgs && $args ? ' ' . implode(' ', $args) : '';
    // PHP_BINARY return the current sapi executable
    if (\PHP_BINARY && \in_array(\PHP_SAPI, [
        'cli',
        'cli-server',
        'phpdbg',
    ], true)) {
        return \PHP_BINARY . $args;
    }
    if ($php = getenv('PHP_PATH')) {
        if (!@is_executable($php) || @is_dir($php)) {
            return false;
        }
        return $php;
    }
    if ($php = getenv('PHP_PEAR_PHP_BIN')) {
        if (@is_executable($php) && !@is_dir($php)) {
            return $php;
        }
    }
    if (@is_executable($php = \PHP_BINDIR . ('\\' === \DIRECTORY_SEPARATOR ? '\\php.exe' : '/php')) && !@is_dir($php)) {
        return $php;
    }
    $dirs = [
        \PHP_BINDIR,
    ];
    if ('\\' === \DIRECTORY_SEPARATOR) {
        $dirs[] = 'C:\\xampp\\php\\';
    }
    if ($herdPath = getenv('HERD_HOME')) {
        $dirs[] = $herdPath . \DIRECTORY_SEPARATOR . 'bin';
    }
    return $this->executableFinder
        ->find('php', false, $dirs);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal